DATA Step, Macro, Functions and more

Extract month from a date and convert it into 3 letters in PROC SQL

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 99
Accepted Solution

Extract month from a date and convert it into 3 letters in PROC SQL

proc sql;
  select month(transdate) from table;
quit;

Above gives me the month in numeric i.e 1 2 3 4 etc

I want to convert these numbers to Jan Feb Mar Apr respectively.

 

Is there any function in proc sql allowing this?


Accepted Solutions
Solution
‎03-10-2017 02:09 AM
Super User
Posts: 19,810

Re: Extract month from a date and convert it into 3 letters in PROC SQL

Posted in reply to afiqcjohari

Look at PUT with MONNAME3 format. 

View solution in original post


All Replies
Solution
‎03-10-2017 02:09 AM
Super User
Posts: 19,810

Re: Extract month from a date and convert it into 3 letters in PROC SQL

Posted in reply to afiqcjohari

Look at PUT with MONNAME3 format. 

Frequent Contributor
Posts: 99

Re: Extract month from a date and convert it into 3 letters in PROC SQL

proc sql;
select put(month(transdate),monname3.) as mt from table
;quit;
Super User
Posts: 19,810

Re: Extract month from a date and convert it into 3 letters in PROC SQL

Posted in reply to afiqcjohari

No month function, just the put. 

Frequent Contributor
Posts: 99

Re: Extract month from a date and convert it into 3 letters in PROC SQL

I was about to ask... Thanks Reeza
☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 192 views
  • 3 likes
  • 2 in conversation