View previous topic :: View next topic |
Author |
Message |
er_hariiharan@yahoo.com Beginner
Joined: 06 May 2006 Posts: 1 Topics: 1
|
Posted: Sat May 06, 2006 4:18 am Post subject: Handling dates in SAS of format CYYMMDD |
|
|
Hi All
I am working with Mainframe SAS 8.2 version. I have a file which consists of a date field with non-conventional CYYMMDD format. When I searched in the SAS online documentation, handling this kind of informat was not found. Could anyone help me in this regard.?
My objective is to read this date field and to convert it into any other SAS readable format say MMDDYYYY. _________________ Best Regards
Hariharan |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
kolusu Site Admin
![Site Admin Site Admin](images/ranks/adminpic.jpg)
Joined: 26 Nov 2002 Posts: 12367 Topics: 75 Location: San Jose
|
Posted: Sat May 06, 2006 7:20 am Post subject: |
|
|
er_hariiharan@yahoo.com,
Assuming a value of 0 for 'c' indicates the 20th century (i.e. 19nn) and a value of 1 indicates the 21st century (i.e. 20nn). This technique adds 19,000,000 to the numeric value, which adjusts it to the format of yyyymmdd, then uses the PUT and INPUT functions with the YYMMDD8. Try this
Code: |
DATA TEST;
INP_DATE = 0990503;
INP_DATE = INP_DATE + 19000000;
SASDATE = INPUT(PUT(INP_DATE,8.),YYMMDD8.);
FORMAT SASDATE MMDDYYN8.;
RUN;
PROC PRINT;RUN;
|
Hope this helps..
Cheers
Kolusu _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
www.linkedin.com/in/kolusu |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
advoss Beginner
Joined: 23 Aug 2005 Posts: 26 Topics: 0
|
Posted: Mon May 08, 2006 11:30 am Post subject: |
|
|
We had a similar situation here, where C=1 for 1900 and C=2 for 2000. So, if that is your situation, just change 19000000 in Kolusu's example to 18000000 (or 18E6 if you're lazy like me and don't like counting zeroes). This will handle birthdates in the 1800's if you have to worry about such things. _________________ Alan Voss |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|
|