Date: Wed, 17 Dec 2008 13:19:55 -0800
Reply-To: Bill McKirgan <Bill.McKirgan@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Bill McKirgan <Bill.McKirgan@GMAIL.COM>
Organization: http://groups.google.com
Subject: comparing score range between variables
Content-Type: text/plain; charset=ISO-8859-1
Hi SASers,
I'm trying to think of a more elegant (read shorter) way of coding the
example I provide below. In the example I am comparing a variable
called FSIQ with another variable PIQ to see if PIQ is within plus/
minus 5 points of FSIQ. This works, but I need to apply it to a bunch
of other variables, and would like to avoid a large copy/paste/modify
job that may cause me to introduce errors.
Can anyone suggest one or more shorter ways of doing this? Perhaps an
array? Any help would be greatly appreciated. I'm stumped. Many
thanks in advance.
-- Bill
data testing; set itbs.iq_data_final;
piq_within_5pts = 0;
if fsiq = piq then piq_within_5pts = 1; else
if fsiq = piq + 1 then piq_within_5pts = 1; else
if fsiq = piq + 2 then piq_within_5pts = 1; else
if fsiq = piq + 3 then piq_within_5pts = 1; else
if fsiq = piq + 4 then piq_within_5pts = 1; else
if fsiq = piq + 5 then piq_within_5pts = 1; else
if fsiq = piq - 1 then piq_within_5pts = 1; else
if fsiq = piq - 2 then piq_within_5pts = 1; else
if fsiq = piq - 3 then piq_within_5pts = 1; else
if fsiq = piq - 4 then piq_within_5pts = 1; else
if fsiq = piq - 5 then piq_within_5pts = 1;
put fsiq piq @20 piq_within_5pts ;
run;