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

Hi All,

i have issue regarding reading date from external file suppose i have veriable name Date in external file name test.csv, and in the date variable i have observation containing dates with verious format like below

date

========

1jan2010

112010

01012010

010110

now i wanted to read this file using single inout statement how can i do that? is there something if else logic we can try in input statement with informat considering the all valid SAS informat for date?

Please let me know how i can do that?

Thanks in Advanced,

Tushar J.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

There is no informat that can correctly guess all possibilities.  e.g. does 112010 represent Nov 20, 2010, Jan 1, 2010, or Nov (1), 2010?  Regardless, the following may do what you want:

data have;

  input date anydtdte.;

  format date date9.;

  cards;

1jan2010

112010

01012010

010110

;

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

There is no informat that can correctly guess all possibilities.  e.g. does 112010 represent Nov 20, 2010, Jan 1, 2010, or Nov (1), 2010?  Regardless, the following may do what you want:

data have;

  input date anydtdte.;

  format date date9.;

  cards;

1jan2010

112010

01012010

010110

;

Tushar
Obsidian | Level 7

Thanks a lot Arthur for your Answer, i was under impression that this is something i need to work with informat. Or Proc format procedure...

i was just wondering if you explain me how above program is working step by step, like how sas compile it. cause i never heard about anydtdte. format again Thanks a lot. Your program has certainly solved my issue...

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
  • 2 replies
  • 973 views
  • 0 likes
  • 2 in conversation