BookmarkSubscribeRSS Feed
saroj
Calcite | Level 5
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
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Cynthia_sas
SAS Super FREQ
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
saroj
Calcite | Level 5
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.
deleted_user
Not applicable
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

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!

How to Concatenate Values

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.

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
  • 4 replies
  • 1016 views
  • 0 likes
  • 4 in conversation