BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VarunIyer
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

2 REPLIES 2
data_null__
Jade | Level 19

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.

Tom
Super User Tom
Super User

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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