Help using Base SAS procedures

proc format - PDw.d informat in z/OS - range of bytes in a user defined informat

Reply
Contributor
Posts: 74

proc format - PDw.d informat in z/OS - range of bytes in a user defined informat

SAS version 9.2 in z/OS

I can use the PDw.d informat successfully to read 4 bytes as PD4.0 and output 7 digits, and I can make a user-defined informat out of it.

I can use the PDw.d informat successfully to read 2 bytes as PD2.0 and output 3 digits, but I cannot make a user-defined informat out of it because SAS tries to read 4 bytes instead of 2.

I tried reading 1,2,3,4,5, and 6 bytes, and it can read 4,5, and 6 bytes successfully, but if I try to read 3 or fewer, it reads 4 at least. It refuses to read fewer than 4 bytes.

This the specific code that I used:

   proc format; invalue inhext other=[pd2.] ; run;

I couldn't replicate this apparent problem in Windows, but if somebody can try it in Windows, that would be be great!

Super User
Posts: 9,671

Re: proc format - PDw.d informat in z/OS - range of bytes in a user defined informat

since it is numeric format and length of numeric variable in SAS is only from 3 to 8 .so I don't know if it is your reason.

Contributor
Posts: 74

Re: proc format - PDw.d informat in z/OS - range of bytes in a user defined informat

I don't think it's related to the variable length because I can use the pd2. informat successfully outside of proc format on the same data. That's my current solution - I'm not using the user-defined informat. I'm using the pd2. informat on the input line:

INPUT @1 varname pd2.

This works, but if I try to put the pd2. into a user-defined informat

proc format; invalue inhext other=[pd2.] ; run;

... and then use the informat

INPUT @1 varname inhext.

... SAS tries to read 4 bytes instead of 2 (and I get an error because the data is not right for 4 positions)

Super Contributor
Posts: 358

Re: proc format - PDw.d informat in z/OS - range of bytes in a user defined informat

Since the data is packed, the z/OS mainframe uses the low-order byte to store part of the number and the sign therefore the smallest packed format is 2 bytes which would give you 3 digits and the sign.

Contributor
Posts: 74

Re: proc format - PDw.d informat in z/OS - range of bytes in a user defined informat

The "online" Help says that the smallest numer of byes is 1 for PDw.d informat for z/OS using SAS 9.2

(1 byte or character is also the default width)

Also, the pd2. informat works outside of PROC FORMAT, and PDw.d works inside PROC FORMAT for 5 bytes or longer (I'm now having difficulty with 4 bytes; previously I thought that 4 bytes worked, but now it doesn't seem to work).

The pd2. informat doesn't work for me inside the PROC FORMAT. That's why I posted this in the "SAS Procedures" area of the discussions.

Example of data in 2 dimensions:

----+---1

01

0C

Reading these 2 bytes of input data with a pd2. informat produces an output of 1 (numeric) using an INPUT statement, but I can't make this work inside PROC FORMAT as a user-defined informat.

I can read 5 bytes inside PROC FORMAT using pd5.

----+---1

00001

0000C

Contributor
Posts: 74

Re: proc format - PDw.d informat in z/OS - range of bytes in a user defined informat

PDw.d informat can read shorter-length strings than 5 bytes if it's used with a (default=  ) option in the proc format.

See reminders by jwillis and Jap in the Proc Format - user-defined informat PDw.d in Windows discussion.

This is documented in SAS Help: FORMAT Procedure > INVALUE Statement

Solution for this discussion in z/OS is:

proc format; invalue inhext (default=2) other=[pd2.] ; run;

Ask a Question
Discussion stats
  • 5 replies
  • 280 views
  • 0 likes
  • 3 in conversation