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

Hi,

I have .csv file with 3 million records to create sas data set.

In this file date values are mention as following: only year and month:

1999MAY

2001JAN

2002FEB

1979DEC

how can I read this YYYYMMM date value to create SAS data set with mmddyyyy format as following:

05-01-1999

01-01-2001

02-01-2002

12-01-1979

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You will need to read as a string and switch the year and month position.

data want ;

  input cdate $7.;

  date = input(substr(cdate,5,3)||cdate,monyy7.);

  format date mmddyy10.;

  put date ;

cards;

1999MAY

2001JAN

2002FEB

1979DEC

run;

05/01/1999

01/01/2001

02/01/2002

12/01/1979

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

If I understand your question correctly, I think the following describes your data and a possible solution:

data have;

  input date $;

  cards;

1999MAY

2001JAN

2002FEB

1979DEC

;

data want(drop=indate);

  format date mmddyy10.;

  set have (rename=(date=indate));

  date=input(indate||"01",anydtdte19.);

run;

Tom
Super User Tom
Super User

You will need to read as a string and switch the year and month position.

data want ;

  input cdate $7.;

  date = input(substr(cdate,5,3)||cdate,monyy7.);

  format date mmddyy10.;

  put date ;

cards;

1999MAY

2001JAN

2002FEB

1979DEC

run;

05/01/1999

01/01/2001

02/01/2002

12/01/1979

tom16
Calcite | Level 5

Tom / Art,

Thanks for your answer. This solve my problem. program working like charm,,,,,

Thanks Again,

Tom

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 843 views
  • 3 likes
  • 3 in conversation