From: Scott Bass on

"mahi" <mehetrey.mahender(a)gmail.com> wrote in message
news:d4bccf37-1ffa-491c-84b3-322b4d50659a(a)j8g2000yqd.googlegroups.com...
> On Jul 16, 3:42 pm, Ya <huang8...(a)gmail.com> wrote:
>> On Jul 16, 12:17 pm, greenwillow <yangliuy...(a)gmail.com> wrote:
>>
>>
>>
>>
>>
>> > thank you Ya. But what can I do if the variable names doesn't have a
>> > common index. The variables names are more like aa1bb, aa2bb, ....
>>
>> > On Jul 16, 2:15 pm, Ya <huang8...(a)gmail.com> wrote:
>>
>> > > On Jul 16, 12:13 pm, greenwillow <yangliuy...(a)gmail.com> wrote:
>>
>> > > > I have more than 30 variables. I need to select out the
>> > > > observations
>> > > > which have at least one variable larger than 3(cutoff point).
>>
>> > > > I know I can write as if var1>3 or var2>3 or.................or
>> > > > var30>3; to select out the observations.
>>
>> > > > Is there an easier way to do this?
>>
>> > > Try max() function:
>>
>> > > if max(of var1-var10) > 3;
>>
>> > > HTH
>>
>> > > Ya- Hide quoted text -
>>
>> > - Show quoted text -
>>
>> if you have limited number of variables, simply type in with comma as
>> delimiter:
>>
>> if max(aa1bb,aa2bb,...) > 3;
>>
>> or if all your vars are numeric, you can something like this:
>>
>> if max(of _numeric_) > 3;
>>
>> If you have many numeric vars that should be be included, then you may
>> have
>> to construct the list of var using meta data.
>>
>> HTH
>>
>> Ya
>
> is there any way we can use array here...

Yes but why would you want to? Max with a variable list seems to me the
best practice solution to the problem as stated.

As to the OP's question, if you don't want to type all the variables, and
especially if the desired variables are contiguous in the PDV, you can just
code something like:

data one;
length aa1bb aa2bb aa3bb 8;
input aa1bb aa2bb aa3bb;
cards;
2 1 0
1 2 3
2 3 4
;
run;

data two;
set one;
if max(of aa1bb--aa3bb) > 3;
if max(of aa:) > 3; /* alternative syntax */
run;

Or, you can use the dictionary tables to build your variable list:

proc sql noprint;
select name into :myvars separated by ',' from dictionary.tables where
libname="WORK" and memname="ONE" and name like 'aa%'; /* or name like
'aa_bb' */
quit;

%put &myvars;

data three;
set one;
if max(&myvars) > 3;
run;

For more details read up on variable lists in the Concepts Guide.

HTH,
Scott