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.;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.