001 Christopher Mullens 11/12/1955 $45,200
002 Michelle Kwo 9/12/1955 $78,123
003 Roger W. McDonald 1/1/1960 $107,200
data listMultiple;
infile "d:\sas\list_MultipleBlank.txt";
input id : $3. name & $20.
date1 : mmddyy10. amount : dollar8.;
run;
proc print data=listMultiple;
format date1 mmddyy10. amount dollar8.;
run;
When I try to read the above data, I got the following errors:
17 data listMultiple;
18 infile "d:\sas\list_MultipleBlank.txt";
19 input id : $3. name & $20.
20 date1 : mmddyy10. amount : dollar8.;
21 run;
NOTE: The infile "d:\sas\list_MultipleBlank.txt" is:
File Name=d:\sas\list_MultipleBlank.txt,
RECFM=V,LRECL=256
NOTE: Invalid data for date1 in line 2 1-3.
NOTE: Invalid data for amount in line 2 5-12.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+-
2 CHAR 002 Michelle Kwo 9/12/1955 .$78,123 37
ZONE 3332466666662476222323323333202332333
NUMR 0020D9385CC50B7F0009F12F195509478C123
id=001 name=Christopher Mullens date1=. amount=. _ERROR_=1 _N_=1
NOTE: Invalid data for date1 in line 3 24-24.
NOTE: Invalid data for amount in line 3 27-34.
3 CHAR 003 Roger W. McDonald . 1/1/1960 $107,200 43
ZONE 3332566672522464666662202232323333223332333
NUMR 00302F75207E0D34FE1C4009001F1F196004107C200
id=003 name=Roger W. McDonald date1=. amount=. _ERROR_=1 _N_=2
NOTE: 3 records were read from the infile "d:\sas\list_MultipleBlank.txt".
The minimum record length was 37.
The maximum record length was 43.
NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
NOTE: The data set WORK.LISTMULTIPLE has 2 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.17 seconds
cpu time 0.06 seconds
22 proc print data=listMultiple;
23 format date1 mmddyy10. amount dollar8.;
24 run;
NOTE: There were 2 observations read from the data set WORK.LISTMULTIPLE.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
Hi,
Check this links...
https://communities.sas.com/message/126382#126382
https://communities.sas.com/message/112959#112959
Thanks,
Shiva
Assuming your data reliably follows the pattern that you expect, here's a two-step approach.
First, add this statement before the INPUT statement:
length name $ 20;
Then modify the INPUT statement by removing $20. (but keep the &).
Good luck.
data listMultiple;
infile "d:\sas\list_MultipleBlank.txt" truncover;
length name $20;
input id : $3. name &
date1 : mmddyy10. amount : dollar8.;
run;
After run the above code, I got the following output :
1 Christopher Mullens 001 . .
2 Michelle Kwo 002 09/12/1955 $78,123
3 Roger W. McDonald 003 . .
I think your data lines have characters that you don't expect. I see at least one tab character.
Can you run this and post the log output.
data _null_;
infile <your file>;
input;
list;
run;
data_null_ is correct for this sample data. You can add the EXPANDTABS option to the INFILE statement and your input statement will work.
data listMultiple;
infile tmpfile1 expandtabs;
input id : $3. name & $20.
date1 : mmddyy10. amount : dollar8.
;
format date1 yymmdd10. amount dollar8.;
put _infile_;
put (_all_) (=);
run;
002 Michelle Kwo 9/12/1955 $78,123
id=002 name=Michelle Kwo date1=1955-09-12 amount=$78,123
003 Roger W. McDonald 1/1/1960 $107,200
id=003 name=Roger W. McDonald date1=1960-01-01 amount=$107,200
I think you need add truncover into infile statement , which is a mistake I used to make .
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.