Date: Thu, 18 Jun 1998 14:12:20 -0500
Reply-To: Thomas Hanan <thomas.hanan@PRUDENTIAL.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Thomas Hanan <thomas.hanan@PRUDENTIAL.COM>
Subject: MVS/EBCDIC SAS question, unsigned packed format?
Content-Type: text/plain; charset=us-ascii
Hello SAS-L gurus,
This question falls under the category "there's gotta be a format for
this". I've scanned my battered language manual and tech report P-222, and
unless I've just missed it somewhere, I can't find a format that does what
I want. What I'm looking for is a format that will create an unsigned
numeric value. For example, I want the numeric value 123456789 to show up
as (in hex):
13579
2468F
The PDw. format sticks a sign on the last half-byte (or nibble, as the SAS
manual humorously refers to it) so the if I output this number as PD5., it
shows up as:
13579
2468C
Not a big deal to me, but then again, I'm a SAS programmer, I can read
anything. The problem is, I'm creating this file for a COBOL programmer,
and she doesn't want the sign on there... So, what to do? I've come up
with the following (very ugly) code, which works, but I don't like it.
Please tell me that I just haven't read my documentation thoroughly and
that there's a handy-dandy format to produce the desired output.
Thanks,
Tom
<<< warning, ugly code follows >>>
DATA TEMP;
SSN = 123456789;
DATA TEMP2; SET TEMP;
FILE OUT NOPRINT;
NUM = SUBSTR(PUT(SSN,Z9.),9,1);
PUT @1 SSN PD5. @;
IF NUM = 1 THEN PUT @5 '1F'X;
ELSE IF NUM = 2 THEN PUT @5 '2F'X;
ELSE IF NUM = 3 THEN PUT @5 '3F'X;
ELSE IF NUM = 4 THEN PUT @5 '4F'X;
ELSE IF NUM = 5 THEN PUT @5 '5F'X;
ELSE IF NUM = 6 THEN PUT @5 '6F'X;
ELSE IF NUM = 7 THEN PUT @5 '7F'X;
ELSE IF NUM = 8 THEN PUT @5 '8F'X;
ELSE IF NUM = 9 THEN PUT @5 '9F'X;
ELSE IF NUM = 0 THEN PUT @5 '0F'X;
RUN;
|