Hi,
I'm using SAS on demand and I'm struggling to change a numeric variable to a SAS date.
My numeric variable is SurgStart which has format best12. and informat best32. It contains 8 digits that represents YYYYMMDD
What I want to do is changed SurgStart e.g.20140410 to become the date 2014 04 10 so I can then do time series analysis.
My code is:
data ab1;
set ab;
SurgDate=input(put(SurgStart, best12.), yyyymmdd.);
format SurgDate date8.;
run;
This doesn't work.
Please help!
You're close 🙂 Use the Best8. Format and the appropriate yymmdd8. Informat
data _null_;
SurgStart=20140410;
SurgDate=input(put(SurgStart, best8.), yymmdd8.);
put SurgStart= SurgDate= date8.;
run;
Hi,
data have;
input Surgstart;
datalines;
20140410
;
run;
data want;
set have;
SurgDate=Input( Put( Surgstart, 8.), Yymmdd10.);
format SurgDate Yymmdd10.;
run;
Thanks everyone for answering my question. A combination of the responses seems to have done the trick:
data ab1;
set ab;
SurgDate=input(put(SurgStart, 8.),yymmdd8.);
format SurgDate yymmdd8.;
run;
Thank you so much!
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: