date conversion to character

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

date conversion to character

Hi ,

Pls tell me how to convert a date value(numeric)  into a text and store that in a macro variable..

Like , if  there is a date value  say  19359     which represents   1st feb 2013

then I would like to have a macro variable      xy=feb2013

I tried using input /put  but its very confusing..

Please help...



Accepted Solutions
Solution
‎03-12-2013 05:43 AM
Trusted Advisor
Posts: 1,137

Re: date conversion to character

Hi,

please try the below code

data have;

    input date;

    date1=put(date,date9.);

    call symput("date",substr(date1,3));

    format date date9.;

cards;

19359

;

run;

%put &date;

proc print;

run;

The numeric value provided is of 01Jan2013, the macro resolves to Jan2013. Hope this helps you.

Thanks,

Jagadish

Thanks,
Jag

View solution in original post


All Replies
Solution
‎03-12-2013 05:43 AM
Trusted Advisor
Posts: 1,137

Re: date conversion to character

Hi,

please try the below code

data have;

    input date;

    date1=put(date,date9.);

    call symput("date",substr(date1,3));

    format date date9.;

cards;

19359

;

run;

%put &date;

proc print;

run;

The numeric value provided is of 01Jan2013, the macro resolves to Jan2013. Hope this helps you.

Thanks,

Jagadish

Thanks,
Jag
Contributor
Posts: 42

Re: date conversion to character

Posted in reply to Jagadishkatam

Great Jagadish...  thanks!

Super Contributor
Posts: 578

Re: date conversion to character

I know the question has been answered...but there is a SAS format that does that:

%let xy=%sysfunc(putn(19359,monyy7.));

%put xy=&xy;

xy=JAN2013

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 255 views
  • 3 likes
  • 3 in conversation