Calculate the computed column. Profit is computed as a percentage of Sales. For nonperishable items, the profit is 40% of the sale price. For perishable items the profit is 25%. Notice that in the compute block, you must reference the variable Sales with a compound name (Sales.sum) that identifies both the variable and the statistic that you calculate with it.


      /* Compute values for Profit. */
   compute profit;
      if department='np1' or department='np2' then profit=0.4*sales.sum;
      else profit=0.25*sales.sum;
   endcomp;
run;