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 (March 2002, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 29 Mar 2002 06:45:33 -0800
Reply-To:     paula D <sophe@USA.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         paula D <sophe@USA.NET>
Organization: http://groups.google.com/
Subject:      Re: pairing variables for interaction variables
Content-Type: text/plain; charset=ISO-8859-1

john.hixon@KODAK.COM wrote in message news:<OFFB858931.B9AF889A-ON85256B8A.006AC997@kodak.com>... > From: John Hixon > > > /* > > > paula D <sophe@USA.NET> asked: > > >I have 21 variables in a data set that I want to use to create new > >interaction variables. For example, to use var1 and war72 to create an > >interaction variable > > >var1_war72=var1&war72; > > >Of course, I can type them out one pair at a time. Is there any > >efficienct code to pair them up quickly? assuming I only have SAS Base > >and SAS STATs. > > >Peter replied with a good question: > > >From: Peter Flom <flom@NDRI.ORG> > >Subject: Re: pairing variables for interaction variables > > >I am sure the SAS-gurus here can do this in a jiffy. > > >But, why? > > >Do you really want ALL the two way interactions? That's 21*20/2 = 210 interaction terms. > >There may be an appropriate use of this sort of analysis, but I can't think of one. > > */ > > > * Assuming you rerally need to generate all of the 2way interactions, There are two > easy ways to do this using Procs: Use either PROC TRANSREG or PROC GLMMOD. > I will show code for PROC TRANSREG. You can find examples in the on line help > for Proc GLMMOD; > > > *create some dunny data with 21 'predictor vars' and one response; > data junk (drop=i); > array v{21} v1-v21; > do id=1 to 300; > do i=1 to 21; > v{i}=10*ranuni(1234); > end; > y1=10*v1-10*v2+10*v1*v10+rannor(1234); > output; > end; > run; > > *Print: is this what we want?; > proc print data=junk (obs=5); > run; > > *method 1: use Proc Transreg. Read the doc about this Proc. > VERY powerful!; > > proc transreg replace data=junk; > model identity(Y1) = identity(v1|v2|v3|v4|v5|v6|v7|v8|v9|v10| > V11|v12|v13|v14|v15|v16|v17|v18|v19|v20|v21@2); > output out=result1; > run; > > * note that we now have all of the 2way interactions in columns. We could now use > this data in a subsequent Proc REG; > proc print data=result1 (obs=2); > run; > proc contents data=result1 varnum; > run; > > * method 2: Proc GLMMOD, no time for demo, read the docs!; > > > > > *HTH > John Hixon > Eastman Kodak Co > Rochester, NY USA;

Thank you for all the response.

1. The word 'interaction' in my original message was a miscue. That may remind people of proc genmod, proc logistic, or any regression stuff that has interaction in it. But that is what I posed the question for.

2. They are places/projects where you may find this drill relevant. One case on my hand is to 'validate' some of SAS Enterprise Miner's logistic regression functions. I have searched this newsgroup and www and found a lot options regarding variable selections (stepwise, forward, backward). I am a little convinced that one can NOT count on them too much. But since we licencesed EM, more and more 'Business Users' are 'catching up' fast in doing logistic models, as if no statistical background is necessary. While I am not trying to challenge EM or SI in general (since I myself like STATS very much), I am interested to find out how EM handles selection options. One may tell me to look up the code behind EM projects. But so far I have not seen many cases that I can simulate with STATS.

So, this original question was pretty much for a kind of simulation purpose.

Paula D


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