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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 2 replies
  • 858 views
  • 2 likes
  • 3 in conversation