BookmarkSubscribeRSS Feed
t75wez1
Pyrite | Level 9

Hi,

Thanks very much for your help in advance.
 Ethan

 

4 REPLIES 4
ballardw
Super User

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.

t75wez1
Pyrite | Level 9

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,?);

 

 

 

SASKiwi
PROC Star
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;
andreas_lds
Jade | Level 19

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.

SAS Innovate 2025: Register Now

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!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 714 views
  • 1 like
  • 4 in conversation