Hey guys,
I was training a few of my interns and we were working on infile using cards. I landed up at the code below and it surprisingly is working fine against all logic. Can anyone help me solve this mystery? Despite the fact that I have specified Date7. in my informat, I'm able to read the dates right, which are in date9..
data test;
informat DepartureDate date7. ;
length country $11.;
format DepartureDate date9. ;
input Country $ DepartureDate blah $;
cards;
Japan 13may2000 a
New_Zealand 03feb2001 b
Brazil 28feb2001 c
Italy 25apr2001 z
USSR 03jun1997 q
Switzerland 14jan2001 a
Ireland 27aug2000 r
;
run;
proc print;
run;
Regards,
Varun
Looks like it is working because you are using list mode input. So it is smart enough to see that the full token of text is 9 characters and uses them all.
Compare with these two INPUT statements.
input Country $ DepartureDate date7. blah $;
input Country $ DepartureDate :date7. blah $;
I think the length is ignored when using LIST input. List input reads until it finds blank. Now let me see if I can find where that is documentated.
Looks like it is working because you are using list mode input. So it is smart enough to see that the full token of text is 9 characters and uses them all.
Compare with these two INPUT statements.
input Country $ DepartureDate date7. blah $;
input Country $ DepartureDate :date7. blah $;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.