Hey guys, hope you're doing well. In my data I have 89 variables (called code_sd1, code_sd2, code_sd3, ...) and one variable (called main_3) , and each variable has a different value. For example the value "E123". There is always a letter and then a number, sometimes just two numbers, sometimes more. Now I want to make a new variable, called "NEW" which includes on the one hand all 89 variables (code_sd1, ...), and that one variable (main_3). So basically i tried this: proc format; value dummy 0 = "no" 1 = "yes"; run; NEW = 0;
if (main_3 EQ 'E123' or code_sd1 EQ 'E123') then NEW = 1;
else NEW = 0;
;
format NEW dummy.; run; And then I create a table with: proc freq data = example; tables sex; where NEW = 1; run; In that table I want to see, how many times main_3 or all 89 codes have the value "E123". As you may have seen, in my code I wrote "if (main_3 EQ 'E123' or code_sd1 EQ 'E123') then NEW = 1;" Because I do not know how to write it, that all 89 code_sd variables are included. If I write code_sd1-89 it doesn't work. Well there is no error, but the numbers in the tables are wrong. If I write code_sd: it doesn't work either (ERROR 388-185: Expecting an arithmetic operator. ERROR 200-322: The symbol is not recognized and will be ignored. ERROR 76-322: Syntax error, statement will be ignored.). I could write down: "if (main_3 EQ 'E123' or code_sd1 EQ 'E123' or code_sd2 EQ 'E123' or code_sd3 EQ 'E123') then NEW = 1;" But it's not smart. I hope you understand my problem and have a solution. Thanks for your time!
... View more