I have a variable called date that's in the format yymmdd10., and I need to convert it in a numeric value, for example: 2022-04-18 will be converted into 20220418 (or look different, as long as it's a number) as a numeric variable.
I have tried this code but it doesn't work. the output variable n is all empty.
DATA want;
SET have;
n=input(put(date, yymmdd10.), 8.);
put n=;
RUN;
appreciate the help!
Just change the format to
yymmddn8.
This changes the appearance. If you really need to change the underlying value, then try
data want;
date='18APR2022'd;
new_date=vvalue(date);
format date yymmddn8.;
run;
Just change the format to
yymmddn8.
This changes the appearance. If you really need to change the underlying value, then try
data want;
date='18APR2022'd;
new_date=vvalue(date);
format date yymmddn8.;
run;
I created your "have" dataset.
data have;
input date $10.;
datalines;
2022-04-18
run;
DATA want;
format n yymmdd10.;
SET have;
n=input(date, yymmdd10.);
put n= ;
RUN;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.