DATA Step, Macro, Functions and more

Informat acting funny!!

Accepted Solution Solved
Reply
New Contributor
Posts: 4
Accepted Solution

Informat acting funny!!

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


Accepted Solutions
Solution
‎01-15-2013 09:56 AM
Super User
Super User
Posts: 6,502

Re: Informat acting funny!!

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 $;

View solution in original post


All Replies
Respected Advisor
Posts: 3,777

Re: Informat acting funny!!

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.

Solution
‎01-15-2013 09:56 AM
Super User
Super User
Posts: 6,502

Re: Informat acting funny!!

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 $;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 154 views
  • 3 likes
  • 3 in conversation