| 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 |
|
| 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 #
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
>
|