Hi everyone. I am trying my script, to get "datetime" in the format of "201808" into datetime.
Here is the code:
%let period=201808;
Period=input(catx(':',put(&period, date9.),'00:00:00'), datetime.);I am expecting to see the result of : 01Aug2018:00:00:00, in datetime format.
However, I am only getting the result of 13JUL2512:00:00:00
What could be wrong?
%let period=201808;
Data want;
Period=.;
run;
data want;
Period=input(catx(':',put(input("&period", yymmn6.),date9.),'00:00:00'), datetime.);
format period datetime20.;
run;
data want;
Period=input(catx(':',put(input("&period", yymmn6.),date9.),'00:00:00'), datetime.);
format period datetime20.;
run;
&period contains just a number. Interpreting that number as a SAS date value (what you do with
put(&period, date9.)
) renders a date that is 201808 days after 1960-01-01, which gives you that day in 2512.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.