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-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 2317 views
  • 0 likes
  • 3 in conversation