IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Date fomat in SAS


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Wed Aug 06, 2008 6:07 pm
Reply with quote

Hi,

Iam having trouble in formatting date in Packed Decimal whihc is 2003073. I need to convert this date into MMDDYYYY format.

When i tried using "PUT" and "INPUT" instructions it was giving an invalid date as 03/25/7444.
If you have any idea please let me know......
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Aug 06, 2008 7:04 pm
Reply with quote

Code:

INPUT     @01  DATEIN    PK4.;           
DATEXX = INPUT(PUT(DATEIN,$8.),YYMMDD8.);

Puts the PK4. value from the input into the SAS base date format, so you can then play around with a new output format.
Back to top
View user's profile Send private message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Wed Aug 06, 2008 7:08 pm
Reply with quote

I have tried with this but it was shoeing this error:
INPUT @42 RIN_SYSDT PK4.;
SYS_DATE = INPUT(PUT(RIN_SYSDT,$8.),MMDDYY8.);
Variable RIN_SYSDT has already been defined as numeric.
FORMAT SYS_DATE MMDDYY10.;

Thank You
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Aug 06, 2008 7:11 pm
Reply with quote

This is what I get
Code:

3          DATA OUT01;                                       
4            INFILE    DATEFILE;                             
5            INPUT     @01  DATEIN    PK4.;                 
6            DATEXX = INPUT(PUT(DATEIN,$8.),YYMMDD8.);       
WARNING: Variable DATEIN has already been defined as numeric.
7            FORMAT   DATEXX   MMDDYY10.;                   

Followed by the output of PROC PRINT ..............

The SAS System         
                       
 DATEIN         DATEXX
                       
20071101    11/01/2007
Back to top
View user's profile Send private message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Wed Aug 06, 2008 7:17 pm
Reply with quote

but for me when i try it was showing incorrect date as:
RIN_SYSDT=2003073 SYS_DATE=.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed Aug 06, 2008 7:50 pm
Reply with quote

try something like this to see the values that get created with each part, and try to see where your error is.
Code:

DATA OUT01;                         
  INFILE   DATEFILE;               
  INPUT    @01  DATEIN    PK4.;     
  DATEXX = PUT(DATEIN,$8.);         
  DATEYY = INPUT(DATEXX,YYMMDD8.); 
                                   
PROC PRINT DATA=OUT01 NOOBS;       
Back to top
View user's profile Send private message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Thu Aug 07, 2008 12:05 pm
Reply with quote

Please find the below output which i have got for the date formats.
RIN_
SYSDT SYS_DATE

2003073 .
2003133 .
2003209 .
2004076 .
2004162 .
2004313 .
2006199 .

If you observe the field RIN_SYSDT, the first 4 digits are always having year(i.e, 2003,2004,2006 etc). If we convert the remaining 3 digits to month and date then we may be getting the correct format.
Any sugeestions on this?

Thank you,
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 07, 2008 12:41 pm
Reply with quote

Quote:
INPUT @42 RIN_SYSDT PK4.;

Can you post the exact hexadecimal data at pos 42 length 4 ?
Back to top
View user's profile Send private message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Thu Aug 07, 2008 12:46 pm
Reply with quote

please find the below data
RIN_SYSDT=2003073

4----+----
7020034444
5C037C0000
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 07, 2008 12:59 pm
Reply with quote

Ok, so I had set my date up as a Packed UNSIGNED field, and yours is signed, so swap PK4. into PD4.

You then need to put this julian date into SAS base date format and then put it into mmddyyyy format.

Shouldn't be too difficult

Race yah icon_biggrin.gif
Back to top
View user's profile Send private message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Thu Aug 07, 2008 1:04 pm
Reply with quote

i have tried with PD4, i was not able to get it..plz help me...
INPUT @42 RIN_SYSDT PD4.;
SYS_DATE = INPUT(PUT(RIN_SYSDT,$8.),MMDDYY8.);
FORMAT SYS_DATE MMDDYY10.;
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 07, 2008 1:15 pm
Reply with quote

You will need to look at the various date functions of SAS to convert one date format into another.

I have told you above what I would do, but unfortunately do not have the time to do both our jobs. As I get paid for mine - it sort of gets preference.

Quote:
You then need to put this julian date into SAS base date format and then put it into mmddyyyy format.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 07, 2008 2:52 pm
Reply with quote

vasantha: what you need is
Code:
DATEXX = INPUT(DATEIN,JULDATE7.);
to convert a 7-digit Julian date to SAS format. Once it's a SAS date you can output it in whatever format you want.
Back to top
View user's profile Send private message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Thu Aug 07, 2008 3:00 pm
Reply with quote

Yeah just now i tried to convert it to julian date then to MMDDYY10. format now iam able to see correct date.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 07, 2008 3:02 pm
Reply with quote

Robert, did you test that ......................
Code:

7            DATEYY = INPUT(DATEIN,JULDATE7.);                         
                                   _________                           
                                   _________                           
                                   _________                           
                                   48                                 
                                   48                                 
                                   48                                 
ERROR 48-59: The informat JULDATE was not found or could not be loaded.
ERROR 48-59: The informat JULDATE was not found or could not be loaded.
ERROR 48-59: The informat JULDATE was not found or could not be loaded.
Back to top
View user's profile Send private message
vasantha

New User


Joined: 05 Aug 2008
Posts: 16
Location: hyderabad

PostPosted: Thu Aug 07, 2008 3:03 pm
Reply with quote

try giving datejul...
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Aug 07, 2008 6:41 pm
Reply with quote

vasantha wrote:
try giving datejul...


Exactly ..........

I hate SAS date formats and playing around changing them, but after some little testing .........

DATEXX = PUT(DATEJUL(DATEIN),MMDDYY10.);

Using the DATEJUL function, DATEIN is converted to a SAS base date, and that value is then PUT into the required format.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Aug 08, 2008 4:33 am
Reply with quote

JULDATE, DATEJUL ... one of them things! I didn't get a chance to test my code since I'm in class this week and not anywhere close to a mainframe. At least the problem got resolved.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Insert system time/date (timestamp) u... DFSORT/ICETOOL 5
Search our Forums:

Back to Top