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

I have the following the DATASET, I have put 2 spaces between the values of ID & Date and Date & Flag. I am not getting the desired result but the year (i.e. 16 is getting assigned to the FLAG variable) WHEREAS if I am putting only 1 space between ID & Date and Date & Flag then my answer is as desire. Please explain why this is happening.

 


data readin ;
input id date ddmmyy8. flag $ ;
format date ddmmyy8. ;
cards;
1  30/12/16  Y
1  30-08-17  N
1  31-08-18  N
2  30-06-16  Y
2  31-12-18  N
;run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

You are using formatted INPUT, but you have columns that are separated by a delimiter (blank). For this, you need list INPUT.

To use list input with informats, you need to use the colon modifier on the informats:

data readin;
input id date :ddmmyy8. flag $;
format date ddmmyy8.;
cards;
1  30/12/16  Y
1  30-08-17  N
1  31-08-18  N
2  30-06-16  Y
2  31-12-18  N
;

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

You are using formatted INPUT, but you have columns that are separated by a delimiter (blank). For this, you need list INPUT.

To use list input with informats, you need to use the colon modifier on the informats:

data readin;
input id date :ddmmyy8. flag $;
format date ddmmyy8.;
cards;
1  30/12/16  Y
1  30-08-17  N
1  31-08-18  N
2  30-06-16  Y
2  31-12-18  N
;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 315 views
  • 1 like
  • 2 in conversation