View previous topic :: View next topic
|
Author |
Message |
Laxminarsimharao
New User
Joined: 08 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
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 |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
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 |
|
|
Laxminarsimharao
New User
Joined: 08 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
Thank you cpuhawg.
can you help me out how can we convert the 107306 (COMP3) to 02NOV2007 in SAS PRINT procedure ? |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
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 |
|
|
|