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!
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 25. Read more here about why you should contribute and what is in it for you!
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.