Hi,
Below is an example of the data I have.
Both A and B must be character types.
I just want to assign a date format to column A so that I get output as column B.
how can I do this efficiently without any warnings? Please advise.
A | B |
20150107 | 2015/01/07 |
20150207 | 2015/02/07 |
2015 | 2015 |
Is this what you want?
If the string in A can be interpretted as YYYYMMDD then make B have the same date printed with slash delimiters. Otherwise just copy A to B.
data want;
set have;
date = input(a,??yymmdd8.);
if not missing(date) then b=put(date,yymmdds10.);
else b=a;
drop date;
run;
Is this what you want?
If the string in A can be interpretted as YYYYMMDD then make B have the same date printed with slash delimiters. Otherwise just copy A to B.
data want;
set have;
date = input(a,??yymmdd8.);
if not missing(date) then b=put(date,yymmdds10.);
else b=a;
drop date;
run;
Thank you sir.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.