- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content