BookmarkSubscribeRSS Feed
agoldma
Pyrite | Level 9

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!

5 REPLIES 5
Ksharp
Super User

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.

agoldma
Pyrite | Level 9

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)

OS2Rules
Obsidian | Level 7

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.

agoldma
Pyrite | Level 9

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

agoldma
Pyrite | Level 9

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1095 views
  • 0 likes
  • 3 in conversation