We are migrating SAS programs from Mainframe to Unix. In the mainframe, sas programs we have COMP-3 fields using PD formats.
When I was trying to convert the PD formats to Zw.d formats in the unix server, I was getting the error as:
I get the Note in my log:
NOTE: Invalid data for U_PRC in line 291 648-659.
NOTE: Invalid data for NETAMT in line 291 660-671.
ERROR: Limit set by ERRORS= option reached. Further errors of this type will not be
Mainframe SAS Program:
FILENAME MR015B '/u175/MR012/D0902.txt';
DATA
TEMP_C
UPDATE_C;
INFILE
MR015B
;
INPUT
@1 HEADER $CHAR551.
@495 LINECNT 2.
@
;
DO I=1 TO 14 BY 1 UNTIL (I = LINECNT);
ZZ = 552 + (142 * (I-1));
INPUT
@ZZ TRAIL $CHAR35.
@ZZ + 35 RNUM $CHAR9.
@ZZ + 44 SHPQTY 6.
@ZZ + 50 ORDQTY 6.
@ZZ + 56 TRAILB $CHAR40.
@ZZ + 96 U_PRC PD5.2
@ZZ + 107 NETAMT PD5.2
@ZZ + 118 TRAILC $CHAR24.
@
;
*--- UPDATE ORDER QUANTITY -------------------------------------------*;
ORDQTY = ROUND((ORDQTY / 50), 1.0);
*--- UPDATE UNIT PRICE -----------------------------------------------*;
U_PRC = U_PRC * 50;
*--- UPDATE SHIP QUANTITY --------------------------------------------*;
SHPQTY = ROUND((SHPQTY / 50), 1.0);
OUTPUT TEMP_C;
END;
run;
I had just changed the PD5.2 to z11.2 for U_PRC & NETAMT column as follows in the above program:
DO I=1 TO 14 BY 1 UNTIL (I = LINECNT);
ZZ = 552 + (142 * (I-1));
INPUT
@ZZ TRAIL $CHAR35.
@ZZ + 35 RNUM $CHAR9.
@ZZ + 44 SHPQTY 6.
@ZZ + 50 ORDQTY 6.
@ZZ + 56 TRAILB $CHAR40.
@ZZ + 96 U_PRC 11.2
@ZZ + 107 NETAMT 11.2
@ZZ + 118 TRAILC $CHAR24.
@
;
I was getting the error as: Invalid values for U_PRC & NETAMT.
NOTE: Invalid data for U_PRC in line 291 648-659.
NOTE: Invalid data for NETAMT in line 291 660-671.
Please suggest how to make changes for the respective PD format fields.
Thanks & Regards,
SId
How have the mainframe files been transported to Unix? Are they still in EBCDIC format using a binary transfer or not?
If they have converted from EBCDIC to ASCII then most likely your packed decimal fields have been corrupted.
View the file and if character fields are readable then they have been converted to ASCII.
The solution to reading PD fields in Unix is to do a BINARY transfer of the files to Unix, then use the RECFM = S370V option on your FILENAME statement, then use the S370 INFORMATs, like S370FPD.:
Addendum: after using binary during the transport, also use the $EBCDICx. format for character variables.
Conversion of the files has been made and through FTP we are taking the files in the unix server.
We are using Zw.d in place of PD formats, but getting the error as:
Do you mean you used the Zw.d when writing the files on the mainframe? If not, your actions are futile. As already stated, you must transfer files with packed decimal data in them in binary mode and use the mainframe-formats $EBCDIC and S370PD to read the data.
If you converted the files on the mainframe, so that there are no packed decimal data present anymore, you need to inspect the files.
One way is to define a character variable of sufficient size, fill it with the contents of _infile_, and use the substr function to extract the positions that the data step is complaining about.
To summarise Kurt and my responses: to deal with packed decimal mainframe data you have 2 choices:
1) Rewrite the data files on the mainframe converting the PD fields to ordinary numerics, then FTP new files to Unix converting from EBCDIC to ASCII.
2) FTP the files as is to Unix using a BINARY transfer and read using the S370 SAS informats as already described.
You can't read PD fields on Unix if they were converted to ASCII via FTP.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.