DATA Step, Macro, Functions and more

Create year, month, qtr using ddmmyy10. FORMAT

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 81
Accepted Solution

Create year, month, qtr using ddmmyy10. FORMAT

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

 


Accepted Solutions
Solution
‎08-20-2017 06:08 PM
Super User
Posts: 9,551

Re: Create year, month, qtr using ddmmyy10. FORMAT


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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎08-20-2017 06:08 PM
Super User
Posts: 9,551

Re: Create year, month, qtr using ddmmyy10. FORMAT


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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Frequent Contributor
Posts: 81

Re: Create year, month, qtr using ddmmyy10. FORMAT

Posted in reply to KurtBremser
Thank you, it worked.
Super User
Posts: 22,823

Re: Create year, month, qtr using ddmmyy10. FORMAT

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.
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 149 views
  • 1 like
  • 3 in conversation