Date: Tue, 17 Apr 2001 21:13:13 -0000
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Paul Dorfman <paul_dorfman@HOTMAIL.COM>
Subject: Re: Help with pack decimal to sas date field
Content-Type: text/plain; format=flowed
The date can be handled a bit shorter by using the informat yymmdd8. (that
is what actually YYYYMMDD is). Namely,
date = input(put(apptdate,z8.),yymmdd8.));
The internal conversion writes the number extracted from the packed-decimal
form as zero-lead 8-byte character string put(apptdate,z8.), which is then
converted to a SAS date via the yymmdd8. informat.
The time can be is actually easier to process on your case, because SAS has
PDTIME4. informat. However, it requires that the time be stored (in hex) as
0hhmmssF, and in your case, SS is missing. That can be circumvented in the
APPTTIME*100 gives HHMMSS with 0 seconds. The result is converted to
unsigned 4-byte packed-decimal required by the PDTIME4. informat, and
finally the latter is used to achieve the goal. Of course, if in your
*original* comp-3 field, the time were stored as a 6-digit value including
seconds, it could be transformed into a SAS time right on the INPUT
statement PDTIME4. Even though SAS says the packed-decimal must be unsigned
(have F in the last nibble) for PDTIME4. to be used, I have found that the
informat accepts C in the last nibble (but of course not D) as well. The
wording about F apparently comes from the PDTIME4. origin as a means of
reading SMF records.
Paul M. Dorfman
>From: Roberto Aguilar <RXACC@CUNYVM.CUNY.EDU>
>How do I transform a packed decimal field into a SAS >date/time fields so
>that I can avail myself of the >numerous date/time formats? Below is a
>program I wrote >that seems to work, but it looks so COBOL-like (just
> >can't shake off 15 yrs of using that language). I'm >trying to learn SAS.
>Is there a more elegant (read : shorter) solution?
>We are running version 8 of SAS under MVS . . .
>DATA KFX ;
> INFILE KFXTRACT ;
> INPUT @1 TERM 6.
> @919 APPTDATE PD5.
> @924 APPTTIME PD4.
>* value of APPTDATE IS IN YYYYMMDD FORMAT ;
>* value of APPTTIME IS IN HHMM FORMAT ;
> APPTDAT = PUT(APPTDATE,8.) ;
> APPTYYYY = SUBSTR(APPTDAT,1,4) ;
> APPTMM = SUBSTR(APPTDAT,5,2) ;
> APPTDD = SUBSTR(APPTDAT,7,2) ;
> APPTDA = MDY(APPTMM,APPTDD,APPTYYYY) ;
> DROP APPTYYYY APPTMM APPTDD APPTDAT ;
>PROC PRINT; RUN;
>Thanks for any help you can provide
Get your FREE download of MSN Explorer at http://explorer.msn.com