Hello everyone,I think this an easy one...I am trying to do a Recompute, but the results are not what I expect.They are correct, but not what I wanted I am just calculating the percentage of a count.and then I want to compute the totals.I thought with percentages I can just take an average, but thats obviously incorrect.Here is my simple example using car file:

TABLE FILE car
SUM CNT.MODEL
COMPUTE percent_of/D12.2%=IF COUNTRY EQ 'ENGLAND' THEN 2.6 ELSE IF COUNTRY EQ 'FRANCE' THEN 10.4 ELSE IF COUNTRY EQ 'ITALY' THEN 12.07 ELSE 1.2 ;
COMPUTE Random_number/D12.2=CNT.MODEL * percent_of/100 ;
BY COUNTRY
ON TABLE HOLD AS File1 FORMAT BINARY
ON TABLE NOTOTAL
ON TABLE SET CACHELINES 100
ON TABLE SET GRWIDTH 1
ON TABLE SET ASNAMES SUBST
ON TABLE SET HOLDATTRS ON
ON TABLE SET HOLDLIST PRINTONLY
ON TABLE SET STYLE *
END
-RUN
TABLE FILE File1
SUM MODEL
percent_of
Random_number
BY COUNTRY
ON TABLE PCHOLD FORMAT HTML
ON TABLE RECOMPUTE SUM. MODEL AVE. percent_of SUM. Random_number AS 'Total:'
ON TABLE SET CACHELINES 100
ON TABLE SET STYLE *
END
-RUN

The Total for Model and Random_number is correct, its just the sum of the values, but the Total for percent_of field is an average(which of course is the correct average) but I need this total to be (total of random_number/total of Model * 100).So the end result should be 4.44%

Thanks.

This message has been edited. Last edited by: nickz, March 24, 2020 11:40 AM

Since the definition (COMPUTE) of "percent_of" is a fix value depending on COUNTRY value and not a calculation of something,I think that it may be done in several steps since I don't see how it can be in one step due to the "percent_of"

1- Perform the detailed data2- Create the total row based on detail3- Create final report with Detailed & Total data