Hello Everyone, I have the following problem and would like to seek your help. My file has variable Target (taking value 0 or 1) and different family of condition variables: A1, A2 ... ; B1, B2 ... Bn; C1…Cn. I have a code below that create a summary of number of taget=0 and target=1 for each combination of variable and value say A1B1C1 (0, 0,0), A1B1C1 (0, 0, 1) ….. A1B1C2 (0, 0,0), A1B1C2 (0, 0, 1) ….. …. And then get the ratio of there 2 number. This code only get 1 variable from 1 family. Now, I am trying to modify the code so that the output file will create combination within each family, up to a chosen value of combination. Such as: A1 B1 C1 A1A2 B1 C1 (family A has 2 level of combination) … A1 B1 C1 A1 B1B2 C1 A1 B1B2B3 C1 (family B has 3 level of combination) …. A1A2 B1B2 C1 A1A2 B1BB3 C1 I should be able to dictate the maximum within family combination. Any help is very much appreciated. Thank you, HHC data have; input target a1-a3 b1-b3 c1-c3; datalines; 0 1 1 1 1 1 1 2 3 4 0 0 0 1 1 0 0 1 2 4 1 0 0 1 1 0 0 1 2 4 1 1 0 0 0 1 1 1 2 1 1 0 0 0 1 0 1 2 0 2 0 1 1 1 1 0 0 1 3 0 0 0 0 0 1 0 0 1 2 3 1 0 1 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 1 1 ;;;; run; data temp(keep=_a_: _b_: _c_: target); set have; length _a_name _b_name _c_name $ 20; array _a{*} a:; array _b{*} b:; array _c{*} c:; do i=1 to dim(_a); do j=1 to dim(_b); do k=1 to dim(_b); _a_name=vname(_a{i}); _b_name=vname(_b{j}); _c_name=vname(_c{k}); _a_value=_a{i}; _b_value=_b{j}; _c_value=_c{k}; output; end; end; end; run; proc sql; create table want as select _a_name,_b_name, _c_name,_a_value,_b_value, _c_value,sum(target=1)/sum(target=0) as Ratio from temp group by _a_name,_b_name,_c_name,_a_value,_b_value, _c_value; quit;
... View more