BookmarkSubscribeRSS Feed
Fluorite | Level 6
I want to convert character date "JUL 2010" to Sas date value in EURDFDMY7(MMMYYYY) format.

I have done the sub setting

data test.datechar1;
set test.datechar1;
length month $3 year $4;
month=substr (date,1,3);
year=substr (date,5,4);

and concantenated to remove the space between JUL and 2010.

INPUT function does not seems to work for the EURDFDMY7 format in SAS version 8.

Can anyone suggest me any other method to convert character date to sas date in EURDFDMY7 format (MMMYYYY) like JUL2010 .
Calcite | Level 5
*---> create format to convert 3 char month to number.;
data temp(keep=start label fmtname);
retain fmtname "$month2number";
start = 'JAN'; label=1; output;
start = 'FEB'; label=2 output;
start = 'MAR'; label=3; output;
start = 'APR'; label=4; output;
*---> create a temporary format;
proc format cntlin=temp;

data test.datechar1;
set test.datechar1;
length month $3 year $4;
month=substr (date,1,3);
year=substr (date,5,4);
*---> convert the month to a number.;
monthn = put(month,$month2number.);
*---> create a SAS date as though it is the first day of the month.;
sasdateout = mdy(monthn,1,year);
attrib sasdateout length=8 format=EURDFDMY7.;
Rhodochrosite | Level 12
Are you using the correct format?

This works, but may not be what you ask for....

data _null_;
a = today();
put a EURDFMY7.;
b = 'jun 2010';
c = input(compress(b),EURDFMY7.);
put c yymmdd10.;

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!
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
  • 2 replies
  • 3 in conversation