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;
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;
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;
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.
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.;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.