SASnewbie
asked on
How do I convert a 6 position date format to a 10 position date format?
Hi All,
How do I convert the following date to a MM/DD/YYYY format?
112310 to 11/23/2010
Thanks,
SASnewbie
How do I convert the following date to a MM/DD/YYYY format?
112310 to 11/23/2010
Thanks,
SASnewbie
ASKER
Hi theartfuldazzler,
Thanks for responding so quickly.
Is there a way to keep the 'Old_date" name?
Thanks for responding so quickly.
Is there a way to keep the 'Old_date" name?
Hi
DATA _NULL_;
Old_date = '112310';
SAS_Date = INPUT(Old_date, mmddyy.);
Old_date = PUT(SAS_Date, mmddyy10.);
PUT _ALL_;
DROP SAS_Date;
RUN;
DATA _NULL_;
Old_date = '112310';
SAS_Date = INPUT(Old_date, mmddyy.);
Old_date = PUT(SAS_Date, mmddyy10.);
PUT _ALL_;
DROP SAS_Date;
RUN;
Hi
You might have an issue with the length of the Old_Date. If you place a format statement before the SET statement, it should work.
DATA _NULL_;
format Old_Date $10.;
Old_date = '112310';
SAS_Date = INPUT(Old_date, mmddyy.);
New_date = PUT(SAS_Date, mmddyy10.);
PUT _ALL_;
RUN;
You might have an issue with the length of the Old_Date. If you place a format statement before the SET statement, it should work.
DATA _NULL_;
format Old_Date $10.;
Old_date = '112310';
SAS_Date = INPUT(Old_date, mmddyy.);
New_date = PUT(SAS_Date, mmddyy10.);
PUT _ALL_;
RUN;
ASKER
Thanks,
Let me try it and be right back.
Let me try it and be right back.
ASKER
Hi,
I'm not getting it... Here is the section of the log with the error message.
2652 Date = input(stat_date,mmddyy.);
2653 Stat_date = put(date, mmddyy10.);
---------
48
ERROR 48-59: The format $MMDDYY was not found or could not be loaded.
stat_date is in the mmddyy format, is text with length $6.
I'm not getting it... Here is the section of the log with the error message.
2652 Date = input(stat_date,mmddyy.);
2653 Stat_date = put(date, mmddyy10.);
---------
48
ERROR 48-59: The format $MMDDYY was not found or could not be loaded.
stat_date is in the mmddyy format, is text with length $6.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay Thanks,
I will be back in an hour...
I will be back in an hour...
Hi
Its 10pm on my side of the world, I will look again tomorrow first thing
Its 10pm on my side of the world, I will look again tomorrow first thing
ASKER
I was able to make the conversion:
stat2_date = input(stat_date,mmddyy6.);
format stat2_date mmddyy10.;
stat_date = put(stat2_date,mmddyy10.);
Thanks,
stat2_date = input(stat_date,mmddyy6.);
format stat2_date mmddyy10.;
stat_date = put(stat2_date,mmddyy10.);
Thanks,
ASKER
Please cancel this request to close without assigning points
Hi
Just interested - but the answer I gave works - and is identical to your answer... why no points?
Just interested - but the answer I gave works - and is identical to your answer... why no points?
ASKER
Hi theartfuldazzler,
I put in a request for the cancel so I can give you the points.
Sorry about that.
I put in a request for the cancel so I can give you the points.
Sorry about that.
As per comment ID: 34970400, the author agrees that comment ID: 34945923 is the correct solution, and should be granted the points.
ASKER
Thanks again!
Assuming the date is stored as text then:
DATA _NULL_;
Old_date = '112310';
SAS_Date = INPUT(Old_date, mmddyy.);
New_date = PUT(SAS_Date, mmddyy10.);
PUT _ALL_;
RUN;
Effectively, this ocde converts a text field to a SAS date, and then makes that SAS Date into a new text field in the format mm/dd/yyyy.