I have a dataset where I would like to add a new column assigned 'bruks' where if 'champ1', 'champ2', 'champ3' 'champ4' 'champ5' or 'champ6' have any of the following observations; 50 161 183 196 264 331 633 746 798 103 163 524 525 526, it should be assigned as 1 in 'bruks', if neither, it should be assigned 0 in 'bruks'. I really have trouble finding the right type of statement for this, I understand that if, then is not proper with this amount of variables and columns, but cannot seem to make the select -when statement to work properly wither (I amcoding it wrong, obviously ;)) Can anyone help, please? One of my attempts here ( I tried both with end; in all lines, and without, and this only shows the first two *champ*categories): data rrmh.bruks; set rrmh.etresultat; select (champ1); when (50) do; bruks=1; when (161) do; bruks=1; when (183) do; bruks=1; when (196) do; bruks=1; when (264) do; bruks=1; when (331) do; bruks=1; when (633) do; bruks=1; when (746) do; bruks=1; when (798) do; bruks=1; when (103) do; bruks=1; when (163) do; bruks=1; when (524) do; bruks=1; when (525) do; bruks=1; when (526) do; bruks=1; select (champ2); when (50) do; bruks=1;end; when (161) do; bruks=1;end; when (183) do; bruks=1;end; when (196) do; bruks=1;end; when (264) do; bruks=1;end; when (331) do; bruks=1;end; when (633) do; bruks=1;end; when (746) do; bruks=1;end; when (798) do; bruks=1;end; when (103) do; bruks=1;end; when (163) do; bruks=1;end; when (524) do; bruks=1;end; when (525) do; bruks=1;end; when (526) do; bruks=1;end; otherwise; bruks=0; end; run; Thanks in advance!
... View more