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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—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.