BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5

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 REPLY 1
Reeza
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1049 views
  • 0 likes
  • 2 in conversation