June 05, 2007, 05:07 PM
AlagaACROSS Verb Question
FOCUS MVS/390 V7.3
Hi all,
I was wondering if any of you could help me with the following case:
I have a file that looks like this:
ID CustCD CustDT CustAmt
-- ------ -------- -------
01 00001 12/31/04 12.50
01 00002 12/31/05 14.50
02 00001 12/12/05 10.00
03 00001 11/21/04 13.00
03 00001 12/22/05 12.00
I want file to look like this:
ID CustCD CustDT CustAmt CustCD CustDT CustAmt
-- ------ -------- ------- ------ -------- -------
01 00001 12/31/04 12.50 00002 12/31/05 14.50
02 00001 12/12/05 10.00 0 0 0.00
03 00001 11/21/04 13.00 00001 12/22/05 12.00
Your help is greatly appreciated.
Thanks,
Alaga
June 05, 2007, 05:12 PM
susannahAlaga, you're going to want to define a variable that enumerates the number of records per ID.
There are several ways to do this, the least elegant of which might be:
DEFINE FILE ..
FLAG/I4=IF ID NE LAST ID THEN 1 ELSE 1 + LAST ID;
END
TABLE FILE ...
SUM CustCD CustDT CustAMT
BY ID
ACROSS FLAG AS ''
END
June 05, 2007, 05:52 PM
Alan BI think this could be done a little more simply:
-*maybe NODATA if required
SET NODATA=0
TABLE FILE fileName
SUM CustCD CustDT CustAMT
BY ID
ACROSS CUST_CD NOPRINT
END
(There is no such concept as 'least elegant' Susannah, just different approaches.)
June 08, 2007, 09:14 AM
AlagaThank you all for your responses.
It worked both ways.
Your help is greatly appreciated.
Alaga.