Would anyone know the best informat to turn the following character value:
25 July 2016 11:43:20
into a numeric datetime:
thanks
David
Here's one example that may help you.
data example;
x="25 July 2016 11:43:20";
z= dhms(input(cats( scan(x,1), substr(scan(x,2),1,3) , scan(x,3)),date9.),0,0,input(scan(x,4),time8.));
format z datetime20.;
run;
Are the months always the full text, ie December ?
Here's one example that may help you.
data example;
x="25 July 2016 11:43:20";
z= dhms(input(cats( scan(x,1), substr(scan(x,2),1,3) , scan(x,3)),date9.),0,0,input(scan(x,4),time8.));
format z datetime20.;
run;
data example; x="25 July 2016 11:43:20 "; z=input(translate(strip(x),':',' '),anydtdtm32.); format z datetime20.; run; proc print;run;
ANYDTDTM. Powerful. data example; x="25 July 2016 11:43:20 "; z=input(x,anydtdtm32.); format z datetime20.; run; proc print;run;
@Ksharp wrote:
ANYDTDTM. Powerful. data example; x="25 July 2016 11:43:20 "; z=input(x,anydtdtm32.); format z datetime20.; run; proc print;run;
Yields missing value for z in my install (boss still hasn't updated from 9.2). I tried that first thing so wasn't sure whether it would work on others.
Ou. Are you still using SAS9.2 . That is almost ten years ago . I am using UE, it is working for me .
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.