Hello,
I have a dataset that I'd like to recode as followings:
recode the variables with the smallest value of 0.000623175 to polytomous items with 4 scores (0,1,2,3)
recode the variables with the smallest value of 0.001041523 to polytomous items with 3 scores (0,1,2)
and recode the variables with the smallest value o f0.002864969 to polytomous items with dichotomous.
Thank you
My code doesn't work:
data coded (drop=score1-score116 i);
set itemsc;
array score (116) score1-score116;
array f_item(116);
array t_item(116);
array d_item(116);
do i=1 to 116;
if score{i} lt 0.000623175 then DO;
if score{i} lt 0.000623175 then f_item{i}=3;
else if score{i} lt 0.002864969 then f_item{i}=2;
else if score{i} lt 0.013617708 then f_item{i}=1;
else if score{i} le 0.431834293 then f_item{i}=0;
if score{i} lt 0.001041523 then do;
if score{i} lt 0.001041523 then t_item{i}=2;
else if score{i} lt 0.008116862 then t_item{i}=1;
else if score{i} le 0.431834293 then t_item{i}=0;
else do;
if score{i} lt 0.002864969 then d_item{i}=1;
else if score{i} le 0.431834293 then d_item{i}=0;
end;
end;
end;
end;
run;
1) Look at where you end statements are.
2) Take a look at the condition that makes you enter the loop, first do
and then the lines after that. Those conditions will never be true.
I suggest getting the code working for one variable then moving on to implementing with an array.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: