Table Lookup using Formats, and Put & Input Functions
Formats may be constructed and saved that contain lookup tables. You may modify the format to change the lookup values as needed without having to modify the programs that use the lookup values.
Example 4 from C&P (with slight modifications):
Proc Format;
Value partdesc
123="HAMMER" 232="PLIERS" 333="SAW" 432="NAILS" 587="SCREWS"
OTHER="Not Entered";
Value price
123="$25.00" 232="$8.50" 333="$18.00" 432="$0.01" 587="$0.05"
OTHER=" ";
Data Invoice;
Input Part_no Quantity @@;
Datalines;
333 10 432 1000 123 15
;
Data Lookup2;
Set Invoice;
Partname= Put(Part_no, Partdesc.);
Price = Input(Put(Part_no, Price.), dollar6.2);
Total = Quantity * Price;
Format Price Total dollar10.2;
Proc Print data=Lookup2;
Title "Total Price per Invoice";