Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Date fomat in SAS

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: Date fomat in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Wed Aug 06, 2008 7:04 pm    Post subject:
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    Post subject: Reply to: Date fomat in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Wed Aug 06, 2008 7:11 pm    Post subject:
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    Post subject: Reply to: Date fomat in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Wed Aug 06, 2008 7:50 pm    Post subject:
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    Post subject: Reply to: Date fomat in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 07, 2008 12:41 pm    Post subject:
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    Post subject: Reply to: Date fomat in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 07, 2008 12:59 pm    Post subject:
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    Post subject: Reply to: Date fomat in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 07, 2008 1:15 pm    Post subject:
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: 7905
Location: Bellevue, IA

PostPosted: Thu Aug 07, 2008 2:52 pm    Post subject:
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    Post subject: Reply to: Date fomat in SAS
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: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 07, 2008 3:02 pm    Post subject:
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    Post subject: Reply to: Date fomat in SAS
Reply with quote

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

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Aug 07, 2008 6:41 pm    Post subject: Re: Reply to: Date fomat in SAS
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: 7905
Location: Bellevue, IA

PostPosted: Fri Aug 08, 2008 4:33 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm
No new posts Add system date inside of a PS file a... pramitdas DFSORT/ICETOOL 5 Sun Aug 28, 2016 12:06 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us