- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi team.
can you please assist with converting a date field from DD/MM/YYYY to YYYY/MM/DD however the data type does not change to date format.
here is my code, however my out put looks like the below
DATA WANT;
SET have;
NEW_DAT = PUT ( INPUT(CREATEDDATE, MMDDYY10.), YYMMDDS10. );
KEEP CREATEDDATE NEW_DAT;
RUN;
please assist
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Assuming that the little red A next the variable name in your PHOTOGRAPH of your data indicates that it is already character you should remove part of that function sandwich so that you create an actual numeric date value instead of another character string.
Make sure you read the character string using an INFORMAT that matches the style of date strings that the variable contains. There is no month number 15 so you cannot use the MMDDYY informat.
You can then attach ANY date type format to the variable and SAS will display in the style that format generates.
DATA WANT;
SET have;
NEW_DAT = INPUT(CREATEDDATE, DDMMYY10.) ;
format new_dat yymmdds10. ;
KEEP CREATEDDATE NEW_DAT;
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Assuming that the little red A next the variable name in your PHOTOGRAPH of your data indicates that it is already character you should remove part of that function sandwich so that you create an actual numeric date value instead of another character string.
Make sure you read the character string using an INFORMAT that matches the style of date strings that the variable contains. There is no month number 15 so you cannot use the MMDDYY informat.
You can then attach ANY date type format to the variable and SAS will display in the style that format generates.
DATA WANT;
SET have;
NEW_DAT = INPUT(CREATEDDATE, DDMMYY10.) ;
format new_dat yymmdds10. ;
KEEP CREATEDDATE NEW_DAT;
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
i have try your code, however am getting the below results
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Make sure to use an INFORMAT that can handle the strings. There is no month number 15.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content