DATA Step, Macro, Functions and more

how to solve below example in base sas and sql

Accepted Solution Solved
Reply
Contributor
Posts: 22
Accepted Solution

how to solve below example in base sas and sql

data have;
input ReAdm1-ReAdm2;
datalines;
1 2012

2 2013

3 2015

;

run;

 

want output in one column like JAN-2012,FEB-2013,MAR-2015 

what i can do for it 

 

thanks in advance  


Accepted Solutions
Solution
‎11-05-2017 12:01 AM
Super User
Posts: 24,010

Re: how to solve below example in base sas and sql

Posted in reply to ganeshmule

MDY function in either data step or SQL. 

In the future please post what you've tried ahead of time so we can effectively help you. 

View solution in original post


All Replies
PROC Star
Posts: 1,401

Re: how to solve below example in base sas and sql

Posted in reply to ganeshmule

like this?

 

data have;
input ReAdm1 ReAdm2;
datalines;
1 2012
2 2013
3 2015
;
run;

data want;
   set have;
   date = mdy(ReAdm1,1,ReAdm2);
   format date monyy7.;
run;
Solution
‎11-05-2017 12:01 AM
Super User
Posts: 24,010

Re: how to solve below example in base sas and sql

Posted in reply to ganeshmule

MDY function in either data step or SQL. 

In the future please post what you've tried ahead of time so we can effectively help you. 

Contributor
Posts: 22

Re: how to solve below example in base sas and sql

[ Edited ]

Thank you for reply but i know that answer is coming like that 

 

put date monyy7.; 
MAY2012

 

but you have not seen my questions properly i want   MAY-2012 instead of MAY2012  but thank you for time 

i did it.. for less time i asked that question over here

 

 

data have;
input ReAdm1 ReAdm2;
datalines;
1 2012
2 2013
3 2015
;
run;
proc sql;
select *, mdy(readm1, 01, readm2) as date format=date11.,
substr (put(calculated date,date11.),4,length(put(calculated date,date11.))) as date
from have;
quit;

 

Super User
Posts: 24,010

Re: how to solve below example in base sas and sql

Posted in reply to ganeshmule

ganeshmule wrote:

 

but you have not seen my questions properly i want   MAY-2012 instead of MAY2012  but thank you for time 

i did it.. for less time i asked that question over here

 

 


I would like to assume you've tried everything before posting here in the first place. 

FYI - you don't need the third parameter in the SUBSTR function. 

 

data have;
    input ReAdm1 ReAdm2;
    datalines;
1 2012
2 2013
3 2015
;
run;

data want;
    set have;
    mydate=mdy(readm1, 1, readm2);
    mydate2=catx('-', put(mydate, monname3.), put(mydate, year4.));
    mydate3 = substr(put(mydate, date11.), 4);
run;

proc print data=want;
run;

 

 

Contributor
Posts: 22

Re: how to solve below example in base sas and sql

Posted in reply to ganeshmule
Thank you ......😆
☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 238 views
  • 0 likes
  • 3 in conversation