Date: Fri, 29 May 2009 14:41:46 -0400
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Zdeb <msz03@ALBANY.EDU>
Subject: Re: Concatenating variables with same prefix or suffix
would this work just as well (also ... you need the comma in the variable list for use in any of the CAT functions) ...
select name into :namelist separated by ','
where libname="<libarary name>" and memname="<datasetname>" and name like "%_xxx";
U@Albany School of Public Health
One University Place
Rensselaer, New York 12144-3456
> Doesn't matter... : does anything:
> means all variables that start with xxx_
> _xxx is harder, you need to do some computations either with arrays:
> array vars _numeric_;
> do _n_ = 1 to dim(vars);
> if find(vname(vars[_n_]),'_xxx') then concatvar =
> or with a macro list, usually using proc sql to generate it. Something
> proc sql;
> select name into :namelist separated by ' '
> from dictionary.columns
> where libname="<libarary name>"
> and memname="<datasetname>"
> and find(name,"_xxx") > 0;
> will do, and then
> will give you the result you want.
> I suggest using UPCASE in the proc sql, if you end up going that route, as
> the upcase/lowcase of variable names etc. is not alwasy consistent.
> On Fri, May 29, 2009 at 1:24 PM, Sanjeev Kommera <firstname.lastname@example.org>wrote:
>> Thanks Joe, I should have been more clear. example variables will be xxx_
>> and _xxx not col1-col&maxnum
>> --- On *Fri, 29/5/09, Joe Matise <email@example.com>* wrote:
>> From: Joe Matise <firstname.lastname@example.org>
>> Subject: Re: Concatenating variables with same prefix or suffix
>> To: "Sanjeev Kommera" <email@example.com>
>> Cc: SAS-L@listserv.uga.edu
>> Date: Friday, 29 May, 2009, 11:41 PM
>> You might want to be a wee bit more specific - like give example data.
>> In general, yes, there are ways to concatenate variables with similar
>> Prefix is easiest:
>> data test;
>> data test2;
>> set test;
>> x = cats(of x:);
>> Suffix usually requires some array manipulation or a proc sql macro call.
>> Which makes more sense depends on your data.
>> On Fri, May 29, 2009 at 12:51 PM, Sanjeev Kommera <firstname.lastname@example.org<http://email@example.com>
>> > wrote:
>>> Hi, Is there a way we could concatenate variables with either same prefix
>>> or suffix in a dataset. (NOT concatenating datasets).
>>> Also, did anyone try getting Mean(S. D.) or Min, Max (customized stats)
>>> from proc tabulate and would like to share the information. (Nope, not using
>>> data _null_ and concatenating, but getting an output from proc tabulate?)
>>> Thanks very much.
>>> Cricket on your mind? Visit the ultimate cricket website. Enter
>> Cricket on your mind? Visit the ultimate cricket website. Enter now!<http://in.rd.yahoo.com/tagline_cricket_1/*http://beta.cricket.yahoo.com>