DATA Step, Macro, Functions and more

Reading packed decimal field from Mainframes flat file in to Unix

Reply
Contributor
Posts: 69

Reading packed decimal field from Mainframes flat file in to Unix

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

Super User
Posts: 3,254

Re: Reading packed decimal field from Mainframes flat file in to Unix

Posted in reply to Siddhartha

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.:

 

http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#p17nnhja9psp...

Super User
Posts: 7,799

Re: Reading packed decimal field from Mainframes flat file in to Unix

Addendum: after using binary during the transport, also use the $EBCDICx. format for character variables.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 69

Re: Reading packed decimal field from Mainframes flat file in to Unix

Posted in reply to KurtBremser

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: 

 

HEADER=1078490372G0311411150828XPN399921 150831GDOG 00010000000000000000018481334150831+0000000.00+0000531.70M
S9276371D3BCM07SAIASGF00054607528 260550300 000000 402964549700000 00009 BXXA94541
3SILVERSTONE GROUP JOAN EMOND 11516 MIRACLE HILLS DRIVE OMAHA NE681544473 SILVERSTONE
GROUP N/A (402) 964-5497 11516 MIRACLE HILLS OMAHA NE 68154-80066815468154000601
44738006X NNN XB LINECNT=80 I=15 ZZ=2398 TRAILA= RNUM= SHPQTY=. ORDQTY=. TRAILB= U_PRC=. NETAMT=. TRAILC= TEST= ID=
U_PRC2=. SEQ_NUM=1 _ERROR_=1 _N_=1
NOTE: Invalid data for SHPQTY in line 2 596-601.
NOTE: Invalid data for U_PRC in line 2 648-657.
NOTE: Invalid data for NETAMT in line 2 659-668.
 
Please suggest.
 
Thanks & Regards,
Siddhartha
Super User
Posts: 7,799

Re: Reading packed decimal field from Mainframes flat file in to Unix

Posted in reply to Siddhartha

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 7,799

Re: Reading packed decimal field from Mainframes flat file in to Unix

Posted in reply to Siddhartha

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 3,254

Re: Reading packed decimal field from Mainframes flat file in to Unix

Posted in reply to KurtBremser

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.

Ask a Question
Discussion stats
  • 6 replies
  • 1191 views
  • 1 like
  • 3 in conversation