- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have one variable 'birthd' that shows value in character format (e.g. 19890629). I want to convert that into a date variable mmddyy in the same file work.test.
Attached is the below code - the variable date_new shows up as numeric instead of date format.
Much help appreciated.
Thanks,
Neil.
WORK.merged;
WORK.merged_COPY;
date_new = input(birthd, yymmdd8.);
format date_new date10.;
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It works for me.
A SAS date value gets stored in a numeric variable as number of days since 01Jan1960 with a format attached.
data test;
birthd='19890629';
date_new = input(birthd, yymmdd8.);
format date_new date10.;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It works for me.
A SAS date value gets stored in a numeric variable as number of days since 01Jan1960 with a format attached.
data test;
birthd='19890629';
date_new = input(birthd, yymmdd8.);
format date_new date10.;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What do you mean by numeric rather than date format?
SAS has only two variable types, numbers and characters and a "date" variable is a number with a date format, specifically the number of days from Jan 1, 1960.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you want the dates to display in month,day, year format then use a format that will do that. For example for today (06JAN2014) to display as 06012014 you would use:
format date_new mmddyyn8.;