LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments:   To: sas-l@uga.edu
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;


Back to: Top of message | Previous page | Main SAS-L page