I am looking at two procedures to import two txt files in SAS. The first file is fixed width. The second txt file is delimited file. The SAS code attached below:
DATA filename; INFILE "filelocation"; INPUT VAR1 $1-11 VAR2 $13-16 @18 VAR3 MMDDYY10. VAR4 $29-53; INFORMAT VAR1 $11.; INFORMAT VAR2 $4.; INFORMAT VAR3 MMDDYY10.; INFORMAT VAR4 $25.; FORMAT VAR1 $11.; FORMAT VAR2 $4.; FORMAT VAR3 MMDDYY10.; FORMAT VAR4 $25.; ; RUN;
DATA filename; INFILE "filelocation" DELIMITER="|" MISSOVER DSD LRECL=32767; INFORMAT VAR1 $11.; INFORMAT VAR2 $4.; INFORMAT VAR3 MMDDYY10.; INFORMAT VAR4 $25.; FORMAT VAR1 $11.; FORMAT VAR2 $4.; FORMAT VAR3 MMDDYY10.; FORMAT VAR4 $25.; INPUT VAR1 $ VAR2 $ VAR3 VAR4 $ ; RUN;
My questions are:
1. Why does the "INPUT" locate in the beginning of the code in the first procedure, but in the last in the second procedure? Does the order of "INPUT" matters?
In the first procedure, there is a "@18" in front of VAR3, which VAR3 is a variable represents date, and it determines the VAR3 starts from the position 18th. Can all of the variables use this expression? ex. @1 VAR1 $
@13 VAR2 $
@18 VAR3 MMDDYY10.
@29 VAR4 $;In the procedure2,
INPUT VAR1 $
VAR2 $
VAR3
VAR4 $
why doesn't the variable have any number after the "$" sign to determine the length of the variable?
Thank you!