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;
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!
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.