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 (July 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 15 Jul 2009 11:18:47 -0500
Reply-To:   Joe Matise <snoopy369@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Joe Matise <snoopy369@GMAIL.COM>
Subject:   Re: proc sql and ARRAYS
Comments:   To: Kathleen Askland <k.askland@gmail.com>
In-Reply-To:   <200907151550.n6FAl5wg025366@malibu.cc.uga.edu>
Content-Type:   text/plain; charset=ISO-8859-1

I'd probably fall back on macro language to do that. SQL does not have arrays.

This works in one way, though it will give multiple rows if tbl1 matches more than one row of tbl2 - either use select distinct or do something else to avoid that.

data tbl1; do _n_ = 1 to 20; x = _n_*3; output; end; run; data tbl2; array xs x1-x14; keep x:; do _t = 1 to 2; do _n_ = 1 to 14; xs[_n_] = _n_*_t*6; end; output; end; run;

%macro checkvar(var1,var2,num); %do i = 1 %to &num; or &var1 = &var2.&i. %end; %mend checkvar;

proc sql; select x from tbl1 T, tbl2 A where 0=1 %checkvar(tbl1.x,tbl2.x,14); quit;

-Joe

On Wed, Jul 15, 2009 at 10:50 AM, Kathleen Askland <k.askland@gmail.com>wrote:

> Hello. > Is there any way to invoke an array (or something akin to it) in PROC SQL? > I'd like to do a two-table join where the value of variable X in table 1 is > equal to the value of any of 14 variables, X1-X14, in table 2. > Any suggestions would be greatly appreciated. > Kathleen >


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