Hello,
I need to create a variable based on responses from another variable as follows:
if KN2 = 1 and 2, or 3, or 8, AND KN3 = 1, 2, or 3 then I2 = 1; esle I2 = 0.
Right now I'm using the following code:
if ((kn2 = 1 and kn2 = 2) or kn2 in (3,8)) and kn3 in (1:3) then i2 = 1;
else i2 = 0;
Is there a better way to write this code? Thanks!
The question was multiple response, and data were entered as needed; i.e. KN2 = 1 if respondant answered with 1 AND 2, or 3 or 8; 0 otherwise.
What is the correct requirement then?
The question was multiple response, and data were entered as needed; i.e. KN2 = 1 if respondant answered with 1 AND 2, or 3 or 8; 0 otherwise.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.