There's an app for that! Well an R package, anyway, SAScii
, brought to you by the indomitable Anthony Damico. It has two functions: parse.SAScii
and read.SAScii
. I've used it with great success on US gummint CDC files.
install.packages("SAScii")
library(SAScii)
> parse.SAScii("test.sas")
varname width char divisor
1 TIPO_REG 2 TRUE 1
2 COD_UF 2 TRUE 1
3 NUM_SEQ 3 TRUE 1
4 NUM_DV 1 TRUE 1
Warning message:
In readLines(sas_ri) : incomplete final line found on 'test.sas'
-- Then you will need to use read.SAScii for the second step, but you did not offer an appropriate test file for that test.
The input file, 'test.sas' was:
DATA DOM (COMPRESS = YES);
INFILE "...¥T_DOMICILIO_S.txt" LRECL = 164 MISSOVER;
INPUT @001 TIPO_REG $2. /* TIPO DE REGISTRO */
@003 COD_UF $2. /* CモDIGO DA UF */
@005 NUM_SEQ $3. /* NレMERO SEQUENCIAL */
@008 NUM_DV $1. /* DV DO SEQUENCIAL */
RUN;
If you view the "twotorials" on Youtube by Anthony Damico or go to his website you can see why I used the word "indomitable".