Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
Laxminarsimharao

New User

Joined: 08 May 2007
Posts: 26

 Posted: Wed Oct 31, 2007 9:44 pm    Post subject: SAS: How to conver COMP3 date and time to user defined forma 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.

cpuhawg

Active User

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

Posted: Thu Nov 01, 2007 1:09 am    Post subject: Reply to: SAS: How to conver COMP3 date and time to user def

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;
Laxminarsimharao

New User

Joined: 08 May 2007
Posts: 26

 Posted: Fri Nov 02, 2007 7:47 pm    Post subject: Reply to: SAS: How to conver COMP3 date and time to user def Thank you cpuhawg. can you help me out how can we convert the 107306 (COMP3) to 02NOV2007 in SAS PRINT procedure ?
expat

Global Moderator

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

 Posted: Fri Nov 02, 2007 8:40 pm    Post subject: Laxminarsimharao Do you not have your own set of manuals at the shop you work in ? They can be accessed freely at www.sas.com 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.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Merging records, but not all the time prino DFSORT/ICETOOL 17 Sat Feb 17, 2018 4:20 pm Need to identify top 10 costly or tim... ashek15 DB2 4 Wed Feb 14, 2018 3:20 am Logic to skip Maximum time-stamp and ... vickey_dw DB2 2 Thu Feb 01, 2018 11:15 pm Query to skip Max time-stamp and fetc... vickey_dw DB2 8 Sun Jan 28, 2018 1:09 am Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us