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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: