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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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