Hi, I am trying to use proc sql to convert a character date format YYYYMMDD to a number date format YYYYMMDD.
,put(intnx('month', input(strip(put(a.ISSUDATE,8.)),yymmdd10.), -1, 'e'), yymmddn8.) as RTfile_date
So currently, my input 'a.ISSUDATE' is a numeric date variable with format as YYYYMMDD, and my returned 'RTfile_date' is a character with the format YYYYMMDD. How can I change it to a numberic with the same format? Thanks!
Currently you are using PUT() with YYMMDDN8. format to generate a string like '20191231'.
Do you want to generate a date value and attach the YYMMDDN8. (or better the YYMMDD10.) format to the variable?
intnx('month',input(put(a.ISSUDATE,Z8.),yymmdd8.),-1,'e')
as RTfile_date format=yymmddn8.
Or do you want to return a number like 20,191,231 and attach the 8. format to it so it looks like 20191231 when displayed?
input(put(intnx('month',input(put(a.ISSUDATE,Z8.),yymmdd8.),-1,'e'),yymmddn8.),8.)
as RTfile_date format=8.
data a;
date='20191210';
date_n=input(date,yymmdd8.);
format date_n yymmddn8.;
run;
I point out that there is no such thing as a numeric YYYYMMDD, as SAS dates are integers representing the number of days since 1/1/1960. Thus, you need to apply a format so it looks to us humans as 20191210.
Currently you are using PUT() with YYMMDDN8. format to generate a string like '20191231'.
Do you want to generate a date value and attach the YYMMDDN8. (or better the YYMMDD10.) format to the variable?
intnx('month',input(put(a.ISSUDATE,Z8.),yymmdd8.),-1,'e')
as RTfile_date format=yymmddn8.
Or do you want to return a number like 20,191,231 and attach the 8. format to it so it looks like 20191231 when displayed?
input(put(intnx('month',input(put(a.ISSUDATE,Z8.),yymmdd8.),-1,'e'),yymmddn8.),8.)
as RTfile_date format=8.
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.