Please note that for any observation (row), a is not equal to a1, a2, a3, and a4. Basically what I want do is to assign 0/1 to the variables a1-a4 based on variable 'a''s association with b. So for example, when a = 3, b = 1. Now, I want a value of 1 to be assigned to variables a1-a4 whose value anywhere in the dataset is equal to 3. When a1 = 7 (10th observation), then the value of 7 needs to be replaced by 0 since when a = 7 b = 0, and so forth. Any suggestion will be greatly appreciated. Thank you.
For convenience in coding within a DATA step, you can setup an array defined for the range of variables a1-a4 and have a SAS code construct like shown below to assign any of the array variable based on "a" value:
DO X=1 to DIM(your_array);
For the other instances where you are assigning values, simply code an IF THEN ; within the same DATA step.
Here is a link to the SAS support http://support.sas.com/ where you can find SAS-hosted documentation on the ARRAY and other SAS Language references. Also, there are technical conference papers and supplemental SAS examples on the site for general use and reference, using the SEARCH facility.
Scott, I tried to assign numbers just using arrays but it never really worked even after spending considerable time. But the proc format seems to work pretty good. Thanks to you both for great suggestions!!
Similar to my previous post, I need the value of "b", that is associated with a particular "a" value per each month, to replace any a1-a4 value (when a1-a4 equal a) for that month. I got an error saying that values overlap when I ran proc format. Thank you.