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

Gurus -

I want to pull only the month from the datasets. Currently the date is stored as example 12Aug2012. I just need Aug.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Is the value a SAS date, i.e. numeric with a default format of Date9. or is it string?

If a SAS date then you can change the format Monname3. and it will display as Aug.

If need to select a specific month (not including year) of data you can use

if month(datevariablename) = 8; or the number of the month you want if the variable is a SAS date.

View solution in original post

3 REPLIES 3
ballardw
Super User

Is the value a SAS date, i.e. numeric with a default format of Date9. or is it string?

If a SAS date then you can change the format Monname3. and it will display as Aug.

If need to select a specific month (not including year) of data you can use

if month(datevariablename) = 8; or the number of the month you want if the variable is a SAS date.

Rish
Calcite | Level 5

Hi Ballarw -

If we are using proc sql example Select Month(xxxdate) gives me numeric "8", do you know how to change it to display "Aug".

Thanks


PGStats
Opal | Level 21

You can use

select month(xxxdate) as month format=NLSTRMON3.1, ...

this works for locale=English_UnitedStates, for other locales you must adjust the field width. For example, for locale=French_Canada, you must use NLSTRMON5.1 .

PG

PG

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 3324 views
  • 0 likes
  • 3 in conversation