Date: Thu, 1 Sep 2011 15:49:25 -0700
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: sql sum function
In-Reply-To: <201109012215.p81K414S020473@waikiki.cc.uga.edu>
Content-Type: text/plain; charset=utf-8
> -----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
|