LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 19 Dec 2008 00:10:58 -0500
Reply-To:     Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject:      Re: comparing score range between variables
Comments: To: Bill McKirgan <Bill.McKirgan@GMAIL.COM>
In-Reply-To:  <2d90a505-23fe-42fb-be32-009c92dc2974@g1g2000pra.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"

Bill: Now that you have an operator that works effectively, you might consider rethinking the idea of applying it to a laundry list of variables. As an alternative, variables transposed into labelled rows acts as an implicit array with no boundary conditions to handle. An operator will apply to each row of data automatically in, for example, SAS SQL. In some applications this method simplifies solutions dramatically. S

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Bill McKirgan Sent: Thursday, December 18, 2008 2:00 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: comparing score range between variables

On Dec 18, 10:45 am, ms...@albany.edu (Mike Zdeb) wrote: > hi ... Howard already explained where to find the explanation for (-5 > : 5) ... an integer range > > if you have no missing data (it generates a 1), > you could also try the absolute value function > (maybe not as "mysterious" as -5 : 5) ... > > piq_within_5pts = abs(piq - fsiq) le 5; > > ps lots of uses for the ':' ... > > http://www2.sas.com/proceedings/sugi26/p073-26.pdf ("That Mysterious > Colon (:)") > > http://www2.sas.com/proceedings/sugi29/054-29.pdf ("Colonoscopy for > the SAS(r) Programmer") > > (though neither mentions the integer range) > > -- > Mike Zdeb > U@Albany School of Public Health > One University Place > Rensselaer, New York 12144-3456 > P/518-402-6479 F/630-604-1475 > > > > > On Dec 17, 9:34 pm, hs AT dc-sug DOT org ("Howard Schreier)" wrote: > >> On Wed, 17 Dec 2008 13:19:55 -0800, Bill McKirgan > >> <Bill.McKir...@GMAIL.COM> > >> wrote: > > >> >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; > > >> I trust that there are no missing values. Bill's code actually > >> returns a 1 > >> (true) result if both variables are missing; probably not wanted. > > >> Here is a technique which is almost exactly equivalent, but is much > >> shorter and generates a 0 (false) given two missing values: > > >> piq_within_5pts = (piq - fsiq) in (-5 : 5);- Hide quoted text - > > >> - Show quoted text - > > > Howard, > > > I can see this works, but I must confess, I don't understand how 'in > > (-5 : 5)' works as it does. > > > Can you explain it a bit for me? > > > Many thanks, > > Bill- Hide quoted text - > > - Show quoted text -

Great stuff Mike. Thanks for those links, and Thank you Howard for directing me to the IN operator details in the online docs. I like to RTFM, but sometimes it's tough for me to find the right place, or think of the right terms to search for the right places.

I used Howards solution and added a floor function to deal with some of the data that had decimals. The person who is doing the analysis wanted to round down...not up, and did not want to just truncate.

I think we're in business, and I'm much obliged for all the ideas and help.

Bill


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