Hello everyone,
my date format is 2012-11-06 00:00:00
data sj.have;
length date $21.;
date = "2012-11-06 00:00:00";
run;
I want just the date from that string in mm/dd/yyyy (for eg: 03/15/1979) format.
Thanks
data _null_;
datetime = "2012-11-06 00:00:00";
format date date9.;
date = input(substr(datetime,1, 10), yymmdd10.);
put _all_;
run;
data _null_;
datetime = "2012-11-06 00:00:00";
format date date9.;
date = input(substr(datetime,1, 10), yymmdd10.);
put _all_;
run;
Create a date variable, and apply the fitting format:
data sj.have;
length
date $21
num_date 4
;
date = "2012-11-06 00:00:00";
num_date = input(scan(date,1),yymmdd10.);
format num_date mmddyy10.;
run;
Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.
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.