Date: Thu, 16 Dec 2004 12:39:25 -0500
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Subject: Re: SQL Question
Scott wrote:
> Hi,
>
> I want to print the concatenation of a bunch of numeric variables
> using SQL.
>
> Test Data:
>
> data one;
> length x1-x10 8;
> array x{*} x1-x10;
> do i=1 to dim(x);
> x{i}=i;
> end;
> run;
>
> Desired Output:
>
> i x
> ---------------------------
> 11 1 2 3 4 5 6 7 8 9 10
>
> Can this be easily done in SQL, perhaps with some sort of nested
> query?
* version 9 catx() function works like a charm;
* however, data step array syntax [of...] is not understood by SQL :( ;
data one;
length x1-x10 8;
array x{*} x1-x10;
do i=1 to dim(x);
x{i}=i;
end;
mush = catx (' ', of x1-x10);
run;
proc sql;
create table two as
select i, mush, catx (' ', x1,x2,x3,x4,x5,x6,x7,x8,x9,x10) as dude
from one
;
quit;
--
Richard A. DeVenezia
http://www.devenezia.com/
|