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

Hi,

Trying to create year, qtr, month from a date in ddmmyy10. format - not working, any ideas? 

The date field is a text field with $10 length.

'01/31/2017'

 

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

@AZIQ1 wrote:

Hi,

Trying to create year, qtr, month from a date in ddmmyy10. format - not working, any ideas? 

The date field is a text field with $10 length.

'01/31/2017'

 

Thank you

 


This is not a ddmmyy, but a mmddyy format. Use the mmddyy informat in an input function to convert your string to a SAS date variable, and then you can use the year(), month() and qtr() functions to extract the values you want.

If code that you wrote does not work as expected, post the code and the log.

Use the proper posting windows ({i} or "little running man" icon) to preserve formatting.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

@AZIQ1 wrote:

Hi,

Trying to create year, qtr, month from a date in ddmmyy10. format - not working, any ideas? 

The date field is a text field with $10 length.

'01/31/2017'

 

Thank you

 


This is not a ddmmyy, but a mmddyy format. Use the mmddyy informat in an input function to convert your string to a SAS date variable, and then you can use the year(), month() and qtr() functions to extract the values you want.

If code that you wrote does not work as expected, post the code and the log.

Use the proper posting windows ({i} or "little running man" icon) to preserve formatting.

AZIQ1
Quartz | Level 8
Thank you, it worked.
Reeza
Super User
Convert your date to a SAS date.
Use the relevant functions, the names match the terms you're using coincidentally. And as mentioned, if you have issues post your code, log and explain in detail what's not working.

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
  • 3 replies
  • 1619 views
  • 1 like
  • 3 in conversation