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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1168 views
  • 1 like
  • 4 in conversation