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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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