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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.