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_dateSo 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.
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 lock in 2025 pricing—just $495!
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.