BookmarkSubscribeRSS Feed
rasika
Calcite | Level 5

Hello,

I have written below mentioned code for getting Month of Bonus from Hire date but in Month it shows only Jan, as hire date is starting on 1st of any month so its reading the date and showing as jan.the result output is attached for your reference.

 

FORMAT HIRE_DATE date9. BIRTH_DATE DDMMYY10.;*TO FORMAT DATE;
BonusMonth= month(Hire_Date);
format bonusmonth monname3.;

4 REPLIES 4
SASKiwi
PROC Star

How do want it displayed? Like this?

 

BonusMonth = Hire_Date;
format BonusMonth monyy7.;
novinosrin
Tourmaline | Level 20

Your are applying format monname to a number that is a date value rather than a month value. So, upto 31 will ofcourse show as jan for the year 1960. 

 

Try

proc format ;  
 value mn_name 1='January'
               2='February'
               3='March'
               4='April'
               5='May'
               6='June'
               7='July'
               8='August'
               9='September'
              10='October'
              11='November'
              12='December'
           other='Invalid';
run;

and apply:
format bonusmonth mn_name.;
Reeza
Super User

Theres a MONNAME format you can use directly on the date. 

 

Month = put(date, monname.);
rasika
Calcite | Level 5
Thank You Soo muchh

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 867 views
  • 1 like
  • 4 in conversation