```Date: Thu, 8 Oct 1998 10:26:23 -0400 Reply-To: Claudia Bullock Sender: "SAS(r) Discussion" From: Claudia Bullock Subject: Could use some advice about possibly too many if-then statements -Reply Heres another possible solution. It does use the if-then-else construct a couple of times, but I don't think its too excessive. To me it seems straight-forward : data out; set in1; array big scale1-scale10; score1=0; score2=0; score3=0; do i=1 to 10; if big{i} > score1 then do; score3=score2; score2=score1; score1=big{i}; end; else if big{i} > score2 then do; score3=score2; score2=big{i}; end; else if big{i} > score3 then score3=big{i}; end; differ=score2-score3; if score1 ge 65 and score2 ge 65 and differ ge 5 then codetype='y'; else codetype='n'; run; >>> "David E. Elkins" 10/07/98 02:55pm >>> I have a large dataset which contains 10 scale scores for each subject. I am trying to create what is called a 2-point codetype based on these 10 scores as described below. However, I can not figure out how to actually program SAS to read and create these 2-point codetypes. Any suggestions and/or advice would be greatly appreciated. The data looks something like this: ID Scale1 Scale2 Scale3 Scale4 Scale5 Scale6 Scale7 Scale8 Scale9 Scale10 01 100 105 60 60 60 60 60 60 60 60 02 60 60 110 100 100 60 60 60 60 60 03 60 60 60 60 60 60 60 60 110 100 04 60 60 60 60 60 60 60 60 60 60 The requirements for this 2-point codetype are: A. You take the two highest scores out of the 10 (if there is a tie between the 2nd and 3rd highest score, then it is not considered due to C below). B. These 2 highest scores must be >= 65. C. The 2nd highest score must be at least 5 points higher than the 3rd highest score. Thus, in the sample data above, ID numbers 1 and 3 would each receive a 2-point codetype (Scales 1&2 and Scales 9&10, respectively). However, ID numbers 2 and 4 would not receive a 2-point codetype. The only way I can see doing this would be to run a huge number of if-then statements but I figure that there has to be an easier and more efficient way to conduct this. I am really only familiar with basic/stat SAS and have not learned any SQL, etc. Any advice on code or pointing me in the right direction would be greatly appreciated. Thank you in advance. P.S. I want to take this opportunity to thank the group for the information and services they have provided over the years. David Elkis Eastern Virginia Medical School Norfolk, Virginia ```

Back to: Top of message | Previous page | Main SAS-L page