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 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 28 Mar 2002 14:07:04 -0500
Reply-To:     Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Subject:      Re: pairing variables for interaction variables
Content-Type: text/plain; charset="iso-8859-1"

Paula D wrote: > 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;

Hi Paula,

Well, my SQL skills are pretty low, but I figure the only way to improve them is to try a SQL solution every once in a while and then learn from corrections/alternatives posted by others. (e.g. it's no doubt crazy to run two select statements on dictionary.vcolumns, just to grab the same thing twice).

That said, the below seems to do what you want. It creates all possible 2-way interaction terms from the variables in a dataset. You'd need to add to the where statement to exclude your outcome variable, etc.

And Peter Flom is of course correct, just because you *can* do this doesn't mean you *should*.

*test data;

data a; array x{5}; run;

proc sql; select trim(name1)||'*'||name2 into :intlist separated by " " from (select name as name1 from dictionary.columns where libname="WORK" and memname="A" ) , (select name as name2 from dictionary.columns where libname="WORK" and memname="A" ) ; quit;

%put &intlist;

Kindly, --Quentin


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