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!
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.