Hello,
I am using SAS Studio and I tried to create a new variable using conditional logic. The new variable was created successfully (called NewVar).
My original dataset has 140 columns so I was expecting my data set to have 141 columns (with one new variable). However, my new data set only has 33 columns. Why is that?
Below are my codes, really appreciate your help! By the way, is there a way to write a statement to keep ALL the variables?
Data Data_2;
Set WORK.PRINTSORTEDDATA;
Length NewVar 4;
IF B6 = 1 THEN NewVar = 6;
ELSE IF B7 = 1 then NewVar = 5;
else if B7 = 2 then NewVar = 4;
else if B7 = 3 then NewVar = 3;
else if B7 = 4 then NewVar = 2;
else if B7 = 5 then NewVar = 1;
RUN;