I tried to read the following data into SAS:
A.Jones 1-1-60 9-15-96 18JUN12
R.Grandage 03/18/1988 31-10-2007 5jul2012
K.Kaminaka 052903 2012024 12-MAR-12
data library;
infile 'C:\MyRawData\Library.dat' truncover;
informat name $10.;
informat birthday mmddyy6.;
informat issued anydtdte5.;
informat returned anydtdte5.;
input name $ +1 birthday +1 issueddate + 1 returneddate;
format returned date9.;
run;
You can see in the informat I defined the length of the dates are way less than the actual date legnth. But SAS is still reading the data fine. Can anyone explain why? Thanks!
Not test .Can you try:
data library;
infile 'C:\MyRawData\Library.dat' truncover dlm=' '; /*need specify delimiter here*/
input name : $10. birthday : mmddyy6. issueddate : anydtdte5. returneddate : anydtdte5.;
format returned date9.;
run;
Mainly because you are using a LIST mode INPUT statement. That is what it does. It skips over the extra spaces.
If you want it to only input exactly the format you specified then you need to use a FORMATTED mode INPUT statement.
Also why did you include cursor movement commands +1 ?
That could potentially move the cursor past the first character of the next value. So it could read '11JAN2016' as '1JAN2016'.
I disbelieve that issuedate and returneddate were read correctly. You specified different variable names for informat statements.
And with the corrected names the valus for issuedate and returneddate are not correct for the second record because of the +1.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.