BookmarkSubscribeRSS Feed
aman23
Obsidian | Level 7

How to print below date in SAS and then extract date & time part in different variables from the same date??

 

22Feb2019 11:44:00 PM

7 REPLIES 7
novinosrin
Tourmaline | Level 20

is your datetime variable numeric i.e number of seconds from Jan 1,1960  that is formatted in that fashion or character?

 

 

aman23
Obsidian | Level 7

It is numeric, say you are fetching it using datetime() function for the current date & time.

novinosrin
Tourmaline | Level 20

Well I think @Jagadishkatam  's demo does just that. Let us know if you need more

Jagadishkatam
Amethyst | Level 16
data want;
dt='22Feb2019 11:44:00 PM'dt;
date=datepart(dt);
time=timepart(dt);
format dt datetime20. date date9. time time5.;
run;
Thanks,
Jag
aman23
Obsidian | Level 7

is there any format to print the both datetime & time in below format??

 

datetime:- 22Feb2019 11:44:00 PM

time:- 11:44:00 PM

 

 

 

 

aman23
Obsidian | Level 7

Yeah thanks a lot (Y) 

thats solves my problem 🙂

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1060 views
  • 2 likes
  • 3 in conversation