Date: Thu, 1 Sep 2011 18:14:07 -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: sql sum function
In-Reply-To: <941871A13165C2418EC144ACB212BDB0020A2E07@dshsmxoly1504g.dshs.wa.lcl>
Content-Type: text/plain; charset=ISO-8859-1
Sadly no, there isn't a way to do so as far as I know. There are some
instances where you can substitute numbers for column names (such as in
group by - if you've selected a function's result, it's easier to group by
1,2,3 than to list the functions again) but you aren't allowed to use list
constructors.
-Joe
On Thu, Sep 1, 2011 at 5:49 PM, Nordlund, Dan (DSHS/RDA) <
NordlDJ@dshs.wa.gov> wrote:
> > -----Original Message-----
> > From: Arthur Tabachneck [mailto:art297@ROGERS.COM]
> > Sent: Thursday, September 01, 2011 3:15 PM
> > To: SAS-L@LISTSERV.UGA.EDU; Nordlund, Dan (DSHS/RDA)
> > Subject: Re: sql sum function
> >
> > Dan,
> >
> > I can't think of a direct shortcut, but one can always take advantage
> > of
> > dictionary.columns. Would the following suffice?:
> >
> > proc sql;
> > select name into:vars
> > separated by ','
> > from dictionary.columns
> > where libname="WORK"
> > and memname="HAVE"
> > and name like "v%"
> > ;
> > select sum(&vars.) as vsum
> > from HAVE
> > ;
> > quit;
> >
> > HTH,
> > Art
>
> Art,
>
> Yeah, I can do that when the work of typing in the variable names is
> greater than typing in the code to access the dictionary tables (or get the
> variable names in some other manner). I was just hoping I had missed some
> magic incantation that would allow the use of something like the list
> constructors available in the data step (v:, v1-v4, etc.). I have been
> disabused of that notion now. :-)
>
>
> Thanks for the response,
>
> Dan
>
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning, Performance, and Accountability
> Research and Data Analysis Division
> Olympia, WA 98504-5204
>
|