SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Converting numeric yymmn6. to character date9. ?

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 90
Accepted Solution

Converting numeric yymmn6. to character date9. ?

Hello,

I have a numeric variabled called "Period_YYYYMM", which contains values such as "201402". I need to convert it into a character variable which should display the values as for instance "28FEB2014". I imagine this requires a combination of the informat yymmn6., the format date9, the intnx-function (to find the last day per month), and a few put- and input- functions; however I seem unable to figure out the correct application of those. Can someone please offer some guidance on this?

Thanks for your time


Accepted Solutions
Solution
‎03-20-2014 12:50 PM
Super Contributor
Posts: 578

Re: Converting numeric yymmn6. to character date9. ?

Posted in reply to EinarRoed

Do you need it to be character or just display date9.?

data want;

var1=201402;

var2=intnx('month',input(put(var1,$6.),yymmn6.),0,'end');

format var2 date9.;

run;

to be truly character:

data want;

var1=201402;

var2=put(intnx('month',input(put(var1,$6.),yymmn6.),0,'end'),date9.);

run;

View solution in original post


All Replies
Super User
Posts: 19,870

Re: Converting numeric yymmn6. to character date9. ?

Posted in reply to EinarRoed

It always help if you've posted what you tried Smiley Happy

Solution
‎03-20-2014 12:50 PM
Super Contributor
Posts: 578

Re: Converting numeric yymmn6. to character date9. ?

Posted in reply to EinarRoed

Do you need it to be character or just display date9.?

data want;

var1=201402;

var2=intnx('month',input(put(var1,$6.),yymmn6.),0,'end');

format var2 date9.;

run;

to be truly character:

data want;

var1=201402;

var2=put(intnx('month',input(put(var1,$6.),yymmn6.),0,'end'),date9.);

run;

Frequent Contributor
Posts: 90

Re: Converting numeric yymmn6. to character date9. ?

Worked like a charm. Thanks grand wizard. Smiley Happy

🔒 This topic is solved and locked.

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

Discussion stats
  • 3 replies
  • 5387 views
  • 0 likes
  • 3 in conversation