sorting data latest to oldest mmyyyy

Reply
Frequent Contributor
Posts: 89

sorting data latest to oldest mmyyyy

Hello,

I have a variable(DC_Date  as MM/DD/YYYY) and I have one year worth of data(May2012-Apr2013). I want to create a new variable which gives date in month and year format(APR2013 .....May2012) and I want to sort them is in such a way that APR2013 ,MAR2013,FEB2013,JAN2013,DEC2012.....MAY2012. or APR2013 being the first month and May2012 being the last month. I am wondering if there is a way to do that.

Super Contributor
Posts: 578

Re: sorting data latest to oldest mmyyyy

Posted in reply to learner_sas

I don't think you have to create a new variable just to apply a different format.  If you really need to create one....

proc sql;

create table new as

select

     t1.*,  

     intnx('month',dc_date,0,'begin') format=monyy7. as NewDate

from old t1

order by intnx('month',dc_date,0,'begin') desc;

quit;

Ask a Question
Discussion stats
  • 1 reply
  • 268 views
  • 0 likes
  • 2 in conversation