Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Century Portion of Date Not Displaying Dates Correctly

Status
Not open for further replies.

ks01

MIS
Aug 11, 2002
110
US
Hi everyone ...

I am having an issue with the century portion of a date. I am reading in a date value of YYMMDD using a YYMMDD6 informat.

An example is 130113 for January 13, 2013. When I write the value out in my put statement with a format of YYMMDD10, I'm getting the value 1913-01-13. I am expecting 2013-01-13.

I have little experience with SAS and would appreciate any suggestion on how I can get my YYMMDD10 date values to write out with the correct century.

Thank you in advance!
 
Hi sasbuddy ... thank you for the feedback.

I added your suggestion to my options statement, but it didn't seem to work. Here is what I did:

Code:
OPTIONS NOSOURCE YEARCUTOFF = 1920       ;

From my input statement:

Code:
@45 ED_200_PURGE_DATE   YYMMDD6.

From my put statement:

Code:
@41 ED_200_PURGE_DATE   YYMMDD10.

From the SAS log, I see:

Code:
ED_100_EFFECT_DATE=19034

But in my output file I see:

Code:
PURGE DATE=1931-01-17

Would you have any suggestions?

Thank you in advance!
 
Sorry ... I pasted the wrong value from the SAS log ... it should have been:

Code:
ED_200_PURGE_DATE=-10576
 
Hi,

if your input data is like '310117' and if you read it using yymmdd6. format with YEARCUTOFF = 1920. then It will give the date as 1931-01-17 and if you have '130117' as source data then the output with above code is 2013-01-17.

The way YEARCUTOFF option works is like; it takes next 100 yrs into consideration of the year value you specified.
and maches the century value accordingly.

So if you set the YEARCUTOFF = 1920 then it will take into conderation the 100 yrs span starting from 1920 to 2019.

and hence if the date in yymmdd6. format is 310117 it will treat it as 1931-01-17 and not 2031-01-17 as 1931 falls into the considered span and 2031 falls out side of that span.

You should choose the value of YEARCUTOFF option accordingly.

Or else if you want to fix the century part as 20th century only; then in that case I would suggest you to read that value in string format prepend the value with 20 and then process that as date in yymmdd8. format.




sasbuddy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top