Desktop productivity for business analysts and programmers

Recoding a four-digit number into date format

Reply
New Contributor
Posts: 3

Recoding a four-digit number into date format

We have a column of dates in a four digit number format currently (9501). We need this recoded to display something resembeling: Jan,1995 but we can't figure out the function or expression to do so. Any suggestions?? Thanks!! version 7.1

New Contributor
Posts: 3

Re: Recoding a four-digit number into date format

PLEASE HELP!!!

Grand Advisor
Posts: 10,210

Re: Recoding a four-digit number into date format

Recommend making and actual date valued variable. Is that value supposed to be YYMM (year and month?) If so do have ANY years with values less than 20 that would indicate 1915 instead of 2015? If so how do you tell the actual year?

 

data junk;
   date= 9501;
   SASdate= mdy( mod(date,100),1,int(date/100));
   Format sasdate MONYY7.;
run;

proc print; run;
New Contributor
Posts: 3

Re: Recoding a four-digit number into date format

Thank you very much! This worked just as we hoped, perfect!

Respected Advisor
Posts: 4,606

Re: Recoding a four-digit number into date format

Please mark the solution as Accepted.

PG
Respected Advisor
Posts: 3,831

Re: Recoding a four-digit number into date format

Alternatively there is also an informat which can read such strings.

data sample;
  have=9501;
  want=input(put(have,4.),yymmn4.);
  format want monyy7.;
run;
Ask a Question
Discussion stats
  • 5 replies
  • 370 views
  • 2 likes
  • 4 in conversation