BookmarkSubscribeRSS Feed
Anilsk
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);
run;

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 .
2 REPLIES 2
jj030655
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;
...etc...
run;
*---> create a temporary format;
proc format cntlin=temp;
run;

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.;
run;
FredrikE
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.;
run;

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