Hi!
I need some advice on how to generate a new combined variable by using if and then statements. I have created separate variables using the if statement, and I have also used the proc format. But after that, I need to combine the variables. I have been trying to combine those new variables, in something like "if at least two of the three materials (wall, roof, and floor) were finished", but I couldn't. Could you guide me to know how to do it?
This is the SAS code with the variables that I have to combine (wall, roof, and floor).
Thank you for your help
libname Assig2 "/folders/myfolders/study3";
data work.homework2;
set Assig2.homework2;
if HV215 in (31,32,33,34,35,36) then Roof= 1;
if HV215 in (11,12,13) then Roof= 2;
if HV215 in (21,22,23,24,25) then Roof= 3;
if HV213 in (31,33,34,35) then Floor= 1;
if HV213 in (11,12) then Floor= 2;
if HV213 in (21,22) then Floor= 3;
if HV214 in (31,32,33,34,35,36) then Wall= 1;
if HV214 in (11,12,13) then Wall= 2;
if HV214 in (21,22,23,24,25,26) then Wall= 3;
run;
proc format;
value Wall
1="Finished"
2= "Natural"
3= "Rudimentary";
run;
proc format;
value Roof
1="Finished"
2= "Natural"
3= "Rudimentary";
run;
proc format;
value Floor
1="Finished"
2= "Natural"
3= "Rudimentary";
run;
Proc freq data=work.homework2;
tables Wall;
format Wall Wall. ;
run;
Proc freq data=work.homework2;
tables Roof;
format Roof Roof. ;
run;
Proc freq data=work.homework2;
tables Floor;
format Floor Floor. ;
run;