| Introduction to Optimization | 
Use of the DATA step and PROC PRINT is the most common way to produce reports. For example, from the data set solution shown in Figure 1.5, a table showing the revenue of the optimal production plan and a table of the cost of material can be produced with the following program.
  
    data product(keep= _var_ _value_ _price_ revenue) 
         material(keep=_var_ _value_ _price_ cost); 
       set solution; 
       if _price_>0 then do; 
          revenue=_price_*_value_; output product; 
       end; 
       else if _price_<0 then do; 
          _price_=-_price_; 
          cost = _price_*_value_; output material; 
       end; 
    run;
 
  
    /* display the product report */ 
  
    proc print data=product; 
       id _var_; 
       var _value_ _price_ revenue ; 
       sum revenue; 
       title 'Revenue Generated from Tie Sales'; 
    run; 
  
    /* display the materials report */ 
  
    proc print data=material; 
       id _var_; 
       var _value_ _price_ cost; 
       sum cost; 
       title 'Cost of Raw Materials'; 
    run;
 
This DATA step reads the solution data set saved by PROC LP 
 and segregates the records based on whether they correspond to 
 materials or products---namely whether the contribution 
 to profit is positive or negative. 
 Each of these is then displayed to produce Figure 1.8. 
 
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.