⇤ ← Revision 1 as of 2023-03-30 20:36:46
Size: 1051
Comment:
|
Size: 1120
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 40: | Line 40: |
output LIBREF.TABLE1; end; |
|
Line 45: | Line 47: |
output; | output LIBREF.TABLE2; end; |
SAS Reading Data
Input
The primary way to read data into a SAS table is with a data step and the INFILE, INPUT, and OUTPUT statements.
InFile Statement
data LIBREF.TABLE; infile "data.txt" pad missover lrecl=80; run;
The LRECL option specifies the fixed-width size of a record. The MISSOVER and PAD options together ensure that unspecified fields are set to missing.
Input Statement
data LIBREF.TABLE; infile "data.txt" pad missover lrecl=80; input RECTYPE $ 1-1 @ ; if RECTYPE = "1" then do; input RECTYPE $ 1-1 VAR1 2-5 ; output LIBREF.TABLE1; end; else RECTYPE = "2" then do; input RECTYPE $ 1-1 VAR1 2-2 ; output LIBREF.TABLE2; end; run;
As demonstrated above, records can be partially input, processed, then completely input later.