- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Guys,
I have been trying to converting a date to a string of characters using the PUT function:
DATA WANT;
SET HAVE;
DATENEW=PUT(DATE, $8.);
RUN;
Currently my date is in the YYYYMMDD format. And the output of this code transformed the date into numbers:
19860108 becomes 9504
19860109 becomes 9505
So on and so forth. I think the output transformed the YYYYMMDD format into the SAS date format where 19600101 is zero.
How can I transform the YYYYMMDD into characters while keeping exactly what I see previously?
Thanks guys!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Does this do what you want?:
DATA WANT;
SET HAVE;
DATENEW=PUT(DATE, yymmddn8.);
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Does this do what you want?:
DATA WANT;
SET HAVE;
DATENEW=PUT(DATE, yymmddn8.);
RUN;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You also have the alternative of leaving the data exactly as is. When printing, you can always apply a format so you can view it in a more familiar form. That also gives you flexibility of selecting the format you want for each report. If you would like to assign a default format, you can add the FORMAT statement in the DATA step.