Hi,
Thanks very much for your help in advance.
Ethan
Since you don't show any DATE information, i.e. year, month or day of the month. Where would date information come from?
To create a TIME value:
data example; x='11:51:25 AM' ; timevariable = input(x,time11.); format timevariable timeampm.; run;
You could assign any of the time formats for display purposes.
Thanks for the solution.
I got time= substr(date,12,11) from date='05/25/2022 11:51:25 AM'
so the question become how to convert the variable named date='05/25/2022 11:51:25 AM' into internal SAS date.
timevariable = input(date,?);
data want;
date = '05/25/2022 11:51:25 AM';
SAS_Date = input(substr(date, 1, 10), mmddyy10.);
format SAS_Date date9.;
put _all_;
run;
A date requires year, month and day and has no time information, so it is not possible at all. You could convert the string value to a sas time value, as @ballardw has already shown, or to a datetime with any date you want, but that seems pretty pointless.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.