BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
frupaul
Quartz | Level 8

Hi everyone,

 

Please can someone help me out. I am trying to extract the datepart of the following date values (please note they come up as character values in the dataset Im dealing with):

 

19/07/2018 09:34:02 AM

18/07/2018 09:19:50 PM

13/07/2018 06:28:39 PM

12/07/2018 09:58:06 AM

12/07/2018 08:54:34 AM

 

So what I am expecting to achieve to create a new field, with values

 

19/07/2018

18/07/2018

13/07/2018

12/07/2018

12/07/2018

 

Please can anyone give any suggestions.

 

Thanks,

 

Paul

1 ACCEPTED SOLUTION
2 REPLIES 2
Swagat711
Fluorite | Level 6

Hope below query solve your problem

 

data abc;
input datetime $23.;
datalines;
19/07/2018 09:34:02 AM
18/07/2018 09:19:50 PM
13/07/2018 06:28:39 PM
12/07/2018 09:58:06 AM
12/07/2018 08:54:34 AM
run;

 

data test;
set abc;
date_new=input(scan(datetime,1,''),ddmmyy10.);
format date_new ddmmyy10.;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 2 replies
  • 776 views
  • 2 likes
  • 3 in conversation