Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMPUTE field = C1 + C3; problem

Status
Not open for further replies.

Ronze55

MIS
Jul 9, 2004
54
US
Hi Everyone,

I have a problem using COMPUTE.

here is the table

TABLE FILE TEST1
HEADER CENTER
"THIS IS A TEST"
" "

SUM
FIELD1/D12.1 AS 'IRR'
FIELD2/D12.1 AS 'ACT'

ACROSS FREASON AS 'REASON'
COMPUTE TOTFIELD1 = C1 + C5;
COMPUTE TOTFIELD2 = C3 + C7;

BY SORT1
BY SORT2
BY SORT3 -* THIS MAY BE ' ' INSTEAD OF A FIELD NAME
END

the output looks like this

TEST
REASON
SORT1 SORT2 FIELD1 FIELD2 TOTFIELD1 TOTFIELD2


on occasion I will have SORT3 but not always.

WHY Is it that I need to jump two C# fields in order to compute TOTFIELD1 AND TOTFIELD2. I have a book and it is very straight forward, according to it I should be able to use C1+C3 and C2+C4, respectively. However I can not.

this situation is not bad for now. the problem arises when I give this to the user and they request a 3rd sort. by C# values will change and the result will be wrong.

I hope my problem is understandable, thanks in advanced for your help.

cc

PS i am summarizing my table. if SORT3 is not used the statement "BY SORT3" is not included. ex: &Sort3 = 'BY SORT3'


 
After looking at me table code, i realized I also have two recomputes

thanks
cc
 
First, C notation only pertains to VERB OBJECTS. So, adding sort fields has no effect.

The reason you have to use C1+C5, rather than C1+C3, is because you're dynamically changing the format of the verb objects, within the request. In effect, this makes the 'original' field a NOPRINT, and does an additional COMPUTE, of the same name, with the NEW format, equal to that NOPRINTed field. So, your verb objects are:

C1 original FIELD1
C2 re-formatted FIELD1
C3 original FIELD2
C4 re-formatted FIELD2

If you change the format of the fields using a DEFINE, before the request, then you COULD use C1+C3.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top