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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.