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

SAS: How to conver COMP3 date and time to user defined forma


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

New User


Joined: 08 May 2007
Posts: 26
Location: hyderabad

PostPosted: Wed Oct 31, 2007 9:44 pm
Reply with quote

Problem:
Date: 107292 (In COMP3 size 5)
Time: 103352 (In COMP3 size 4)

how can i convert the above values into normal date DDMMYY and HH:MM:SS in SAS PRINT procedure?

please help me.
Back to top
View user's profile Send private message
cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Thu Nov 01, 2007 1:09 am
Reply with quote

Here is the input displayed in HEX (in TSO). DATE in position1 and TIME in position 11:

Code:

----+----1----+
----+----F----+
----+----1----+
---------------
         
000224444403324
0179F00000015F0


We will assume that 107292 is the numeric equivalent of the date. 103352 is an invalid time, so I used 031352.

Here is the SAS code:

Code:

//XSAS1 EXEC SAS RSYSOUT='*',LSYSOUT='*'                   
//SAS.SASLIST  DD SYSOUT=*                                 
//SAS.SASLOG   DD SYSOUT=*                                 
//SAS.INDATE   DD DSN=HLQ.SAS.TEST,DISP=SHR               
//SYSIN DD *                                               
  DATA PROD1;                                               
     INFILE INDATE;                                         
     INPUT  @01 DATE    PD5.                               
            @11 TIME    PD4.;                               
             DATEX = PUT(DATE,DDMMYY6.);                     
            TIMEX = PUT(TIME,TIME8.);                       
  PROC PRINT DATA=PROD1;                                   


So we bring in the DATE and the TIME indicating packed decimal format.
We then take the DATE and TIME and PUT them into a FORMAT (see DATEX and TIMEX).

The printout looks like:

Code:

               The SAS System               
                                             
Obs     DATE      TIME    DATEX      TIMEX   
                                             
 1     107292    31352    031053    8:42:32 


So the DATE of 107292 converts to MMDDYY or 03/10/53 (without the slashes) and the TIME of 031352 converts to 8:42:32.

If you are doing this in a SAS PRINT procedure, you could use something like:

Code:

PROC PRINT DATA=PROD1 NOOBS UNIFORM LABEL;               
TITLE1 'DATE AND TIME';
   FORMAT DATE MMDDYY6.;                                 
   FORMAT TIME TIME8;
       LABEL DATE  ='THE DATE'                           
         TIME = 'THE TIME';                           
        VAR DATE TIME;                 
Back to top
View user's profile Send private message
Laxminarsimharao

New User


Joined: 08 May 2007
Posts: 26
Location: hyderabad

PostPosted: Fri Nov 02, 2007 7:47 pm
Reply with quote

Thank you cpuhawg.

can you help me out how can we convert the 107306 (COMP3) to 02NOV2007 in SAS PRINT procedure ?
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Fri Nov 02, 2007 8:40 pm
Reply with quote

Laxminarsimharao
Do you not have your own set of manuals at the shop you work in ? They can be accessed freely at Use [URL] BBCode for External Links

Take a look at FORMATS in the manuals and your question will be answered.

Are the variables you are using generated by SAS, or merely to be converted by SAS to a different format. SAS uses a base point for its date routines, and if these variables are not SAS generated then you will need to find the base point of these variables and adapt them to fit in with the SAS base point.
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top