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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.