Date: Fri, 16 May 2008 09:44:01 -0700
Reply-To: karma <dorjetarap@GOOGLEMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: karma <dorjetarap@GOOGLEMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Add certain variables across a dataset
Content-Type: text/plain; charset=ISO-8859-1
On May 16, 4:50 pm, shankera <shanker_an...@hotmail.com> wrote:
> I have a dataset with 100s of variables, and I want to add ones with
> the suffix "_pending". Is there a way to do it without having to
> write out 30 some variable names?
The easiest way i can think of is to query the datadictionary and put
it into a macro variable for the summary statistics. You could
transpose the data and do it that way, but that's pretty messy too. If
only it was a prefix and not a suffix, you could use arrays and refer
to the variables as "_pending:". HTH
data new;
input f_pending g_pending l_pending h_pending control;
cards;
5 56 5 2 7
6 2 5 6 52
5 5 4 5 78
6 5 2 8 9
7 5 2 1 7
;
run;
proc sql;
select name
into :value separated by ','
from dictionary.columns
where upcase(libname) ="WORK" and
name like "%_pending";
select sum(&value)
from new;
quit;