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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.