DATA Step, Macro, Functions and more

How to handle the below array file structure in INPUT statement.

Reply
Occasional Contributor
Posts: 16

How to handle the below array file structure in INPUT statement.

I have a flat file in mainframe with a cobol copybook structure as shown below.

i need to read all the INTEGRATED-FORECAST fields for each record in the file in SAS using input statement.

How will the input statement look like ? I don't want to write every array occurence position in the input statement.

please let me know if you require any more info.

05 FORECAST-TABLE OCCURS 0026.
07 INTEGRATED-FORECAST PIC S9(07)V9(02) COMP-3.
07 PLANNED-ORDERS PIC S9(07) COMP-3.
07 LINE-ITEM-COUNT PIC S9(03) COMP-3.

Message was edited by: saroj Message was edited by: saroj
Super Contributor
Super Contributor
Posts: 3,174

Re: How to handle the below array file structure in INPUT statement.

Recommend you provide a data-sample instead of the COBOL. Also, it would be helpful (so subscribers are not left to guess) to learn how you would like to see the final output data.

Scott Barry
SBBWorks, Inc.
SAS Super FREQ
Posts: 8,866

Re: How to handle the below array file structure in INPUT statement.

Hi:
With a signed COMP-3 value, posting the data probably wouldn't help. You might investigate the COB2SAS program, which is a way of essentially translating a COBOL data description into a SAS INPUT statement.

http://support.sas.com/techsup/technote/ts536.html

cynthia
Occasional Contributor
Posts: 16

Re: How to handle the below array file structure in INPUT statement.

Posted in reply to Cynthia_sas
As Cynthia mentioned the data is in packed decimal format so cannt be displayed.

Cynthia cannt we use PD informat for comp-3 data. i have been using it for a long time without any problem.

About COB2SAS utility its not allowed in our shop. I was basically looking at some way to represent an array input where the array element consists of sub elements as is shown in the example above.
N/A
Posts: 0

Re: How to handle the below array file structure in INPUT statement.

once you have positioned the input pointer at the forecast_table, then execute the input statement in a loop, like[pre]
input @1234 @ ; * replace 1234 with the correct position number;
array fcast(3,26) ;
do t=1 to 26 ;
input ( fcast(1,t) fcast(2,t) fcast(3,t) )
( pd5.2 pd4. pd2. ) ;
end ;
[/pre]The input column position for the following field is maintained by the input processing internally. The input pointer moves along the buffer area according to the informat length, which is why for "S9(07)V9(02)" use PD5.2, where 5 is the space in the record for the data, and 2 is for the implied decimal places.
If run-time performance is very important, you can eliminate the array and looping and list all the required variable names, in order, inside the first parenthesis. [pre] input (
intfcast1 pord1 lineItms1
intfcast2 pord2 lineItms2
intfcast3 pord3 lineItms3
.......................... (easy for me, but you need all the vars listed)
intfcast26 pord26 lineItms26 )
( pd5.2 pd4. pd2. ) ; [/pre]
The input processing repeatedly uses the format list (second parenthesis).

Of course, that long variable list in the first parenthesis may be reduced with some macro to generate the long variable list, but I'm not sure which you would prefer.

PeterC
Ask a Question
Discussion stats
  • 4 replies
  • 176 views
  • 0 likes
  • 4 in conversation