I have two tables in SAS, Table A and Table B. Suppose I want to write a little SAS code to obtain the table "Desired Output." How would I do this?
Table A:
Observation Var1 Var2
1 0 0
2 1 2
3 2 1
4 0 0
Table B:
Var Level Lookup
Var1 0 0.1
Var1 1 0.3
Var1 2 0.5
Var2 0 0.7
Var2 1 0.8
Var2 2 0.9
Desired output:
Observation Var1 Var2 Var1_new Var2_new
1 0 0 0.1 0.7
2 1 2 0.3 0.9
3 2 1 0.5 0.8
4 0 2 0.1 0.9
From my understanding, this may involve SQL in SAS, but I'm not sure. I have no idea how to do this. Pseudo-code might look like this, but I don't know how to actually make it work:
data DATA_OUT.DESIRED_OUTPUT;
set DATA_IN.TABLE_A;
set PP.TABLE_B key=(Var Level);
Var1_new = TABLE_B["Var1" Var1][Lookup];
Var2_new = TABLE_B["Var2" Var2][Lookup];
run;
How would you achieve the desired output in SAS?