🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 01-26-2020 12:10 PM
(10457 views)
Hi.
I have a column with datetime values like this: 01.01.20 09:28:35,000000
And I want to change them into this format (YYYY/MM): 2020/01
In Oracle SQL I used function to_char(column_name,'YYYY/MM') but I wasn't able to do the same thing in SAS PROC SQL.
I tried things like put(column_name,yyyySmm7.) but it either doesn't work or date values are out of range or it shows weird numbers...
Can anybody help me with this?
Thanks in advance!
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sounds like you need:
put(datepart(column_name), yymms7.) as yyyysmm
-unison
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sounds like you need:
put(datepart(column_name), yymms7.) as yyyysmm
-unison
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, it is working!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Other approaches you might consider:
Without changing the internal value, assign it SAS Format DTdate9.
Instead of this standard format (as I don't think DTyymms format exists), you can create your own format with your preferred date layout using the Format Procedure)
Without changing the internal value, assign it SAS Format DTdate9.
Instead of this standard format (as I don't think DTyymms format exists), you can create your own format with your preferred date layout using the Format Procedure)