Modifying SAS Data Sets |
You can use the MODIFY statement to replace all values for a specific variable or variables in a data set. The syntax for using the MODIFY statement for this purpose is
MODIFY SAS-data-set; |
In the following program, the price of each part in the inventory is increased by 15%. The new values for PRICE replace the old values on all records in the original INVENTORY data set. The FORMAT statement in the print procedure writes the price of each item with two-digit decimal precision.
data inventory; modify inventory; price=price+(price*.15); run; proc print data=inventory; title 'Tool Warehouse Inventory'; title2 '(Price reflects 15% increase)'; format price 8.2; run;
The following output shows the results:
The INVENTORY Data Set with Updated Prices
Tool Warehouse Inventory 1 (Price reflects 15% increase) Part In Received Obs Number Description Stock Date Price 1 K89R seal 34 27JUL1998 281.75 2 M4J7 sander 98 20JUN1998 52.76 3 LK43 filter 121 19MAY1999 12.64 4 MN21 brace 43 10AUG1999 32.05 5 BC85 clamp 80 16AUG1999 10.98 6 NCF3 valve 198 20MAR1999 28.18 7 KJ66 cutter 6 18JUN1999 22.74 8 UYN7 rod 211 09SEP1999 13.28 9 JD03 switch 383 09JAN2000 16.09 10 BV1E timer 26 03AUG2000 39.68
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.