Hello guys, I am trying to standardize food questionaire scores in such a way that every level or category corresponds to number of times/ day in my data set. For example, i want number 0 in my dataset to be converted to 0, 1 to 1/30, 2 to 1/15, 3 to 1/7 etc. I tried to write a SAS micro for it. Here's my code %macro convert_var(var_in,var_out); if &var_in. = 0 then &var_out. = 0; if &var_in. = 1 then &var_out. = 1/30; if &var_in. = 2 then &var_out. = 2/30; if &var_in. = 3 then &var_out. = 1/7; if &var_in. = 4 then &var_out. = 3/7; if &var_in. = 5 then &var_out. = 6/7; if &var_in. = 6 then &var_out. = 1; if &var_in. = 7 then &var_out. = 2.5; if &var_in. = 8 then &var_out. = 4.5; if &var_in. = 9 then &var_out. = 7; %mend; data work.fooddata; %convert_var(T1,i_T1) %convert_var(T2,i_T2) %convert_var(T3,i_T3) %convert_var(T4,i_T4) run; I ran this code for the first 4 variables that i wanted to convert and it gave me this as my dataset. Note the intial content (before i ran the code) and final content of my dataset(after i ran the code). I will be glad to get help on how to modify my code....or can this be done with a do loop? Please any help will be appreciated!
... View more