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
Use
newdate = input(substr(datestring,1,10),ddmmyy10.);
format newdate ddmmyy10.;
Use
newdate = input(substr(datestring,1,10),ddmmyy10.);
format newdate ddmmyy10.;
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;
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!
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.
Ready to level-up your skills? Choose your own adventure.