BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RandoDando
Pyrite | Level 9

Let me start by saying the subject of the topic makes this seem simpler than it is.  I know how to get a month and year from a date already.  However, the month in this case appears as a number and I want the 3 letter abbreviation.  I tried using the monyy7. format, but using a format only changes the displayed value.  When I try to create another table in a PROC SQL statement to group by the new dates (MONTHYEAR) I get more than 1 row per month because the actual day is being read "behind the scenes".   How can I efficiently convert a date into the APR2022 value without using a format statement?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

So you want a new variable that contains the three letter month?

 

month_abbreviation = put(datevariable,monname3.);

 

While there are certainly good reasons to create this new variable, I point out that it will not sort in any meaningful order, this new variable will sort alphabetically so the first month of the year is APR and the second month of the year is AUG, and that's not usually what people want.

 

If you want the 3 letter abbreviation to appear and still have the months sort properly, then you would apply the format MONNAME3. to your date variable. 

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

So you want a new variable that contains the three letter month?

 

month_abbreviation = put(datevariable,monname3.);

 

While there are certainly good reasons to create this new variable, I point out that it will not sort in any meaningful order, this new variable will sort alphabetically so the first month of the year is APR and the second month of the year is AUG, and that's not usually what people want.

 

If you want the 3 letter abbreviation to appear and still have the months sort properly, then you would apply the format MONNAME3. to your date variable. 

--
Paige Miller
RandoDando
Pyrite | Level 9
Thanks. That should get me where I want to go.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 2191 views
  • 0 likes
  • 2 in conversation