- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi All
I'm facing one issue with the current business date in sas mainframe dataset please find the below mention input data and output screen shot
the input file contains date in a YYMMDDCC format
input file name is nsdate
-----------------------------------------------------------------------------------------------------------
20010320
----------------------------------------------------------------------------------------------------------------
above the input date and
and the sas code has
------------------------------------------------------------------------
data _null_;
infile nsdate;
input @1 date yymmdd6.;
edate=put(date,yymmdd10.);
cudt=compree(translate(edate,' ','-'));
call symput('busdt',cudt);
%put busdt;
run;
--------------------------------------------------------------------------------------------
while run the above code we are getting century mismatch instead of 20 it coming the 19
why bez the date filed has to calculate from 1960 Jan 1 to till date, but up to 2019 Dec 31 it calculates properly
but from 2020 it's not picking
RAM EDTE CDTE
-14608 1920-01-03 19200103
above the output we are getting
may know what it contains going negative values
and moreover for the date field has given yymmdd6. format it must come has 200103 insted of that it given date calculation from 1960 to till date
kindly give some solution for above problem
Thanks & Regards
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
The problem is that you are reading 6-character dates, when doing that you should take a look at the YEARCUTOFF option. It seems that it has been set to 1920 on your system, meaning that year values from 20 to 99 will be read as 1920 to 1999.
Try this:
options yearcutoff=1950;
or something like that, that should correct the problem.
If that is not good enough, you will have to read the century by itself, as I do not think that SAS has an informat like YYMMDDCC, e.g.:
data _null_;
infile nsdate;
input @1 date yymmdd6. century 2.;
if century>int(year(date)/100) then
date=intnx('year',date,100,'same');
edate=put(date,yymmdd10.);
cudt=compree(translate(edate,' ','-'));
call symput('busdt',cudt);
run;
%put &busdt;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
thanks for the quick replay
now it working fine after changes
Thanks a lot lassen
Thanks & regards
rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Another solution would be to read the character string, use prxchange to put CC before YY and store the result in a macro variable. There is no yearcutoff problem because the value is treated as a string and not read as a SAS date.
data _null_;
infile nsdate;
input @1 date $8.;
call symput('busdt',prxchange('s/(\d{6})(\d{2})/$2$1/',1,date));
run;
%put &busdt;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It seems you want a date formatted as yymmddn8. in your macro variable, so you only need to move the century to the front:
data _null_;
infile nsdate;
input @1 date $8.;
call symput('busdt',substr(date,7,2)!!substr(date,1,6));
run;
%put &busdt.;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@rohitkrishna wrote:
Hi All
I'm facing one issue with the current business date in sas mainframe dataset please find the below mention input data and output screen shot
the input file contains date in a YYMMDDCC format
Your question subject line says that the date is in CCYYMMDD format. But you say the value is YYMMDDCC. So, which is it actually?
I haven't ever seen anything with YYMMDDCC so am wanting to make sure that you are providing the correct information.
Personally if I ever run into a YYMMDDCC date I am going to beat someone about the head and shoulders and yell "What were you thinking!"