Date: Wed, 11 Feb 2009 13:15:00 -0500
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: Different WHERE statements for different variables?
On Wed, 11 Feb 2009 12:02:51 -0600, ./ ADD NAME=Data _null_;
<iebupdte@GMAIL.COM> wrote:
>On 2/11/09, Gerhard Hellriegel <gerhard.hellriegel@t-online.de> wrote:
>> What IS the correct output? Only for my understanding: is the goal to
>> summarize weight with the first subset (sex="F"), then "add" the second
>> (age>14) to summarize height?
>
>The output is incorrect in the context of the originating question.
>As I see it the OP wants different subset for different variables,
>summarized in one PROC SUMMARY. And as you say not possible with
>WHERE. I think the only working solutions have been proposed by data
>_null_ and Art.
>
After reading it again and again I think I'm now on the right track! Maybe
simply my english is too bad to read "between the lines". So I was
wandering why someone wanted to split a WHERE clause in parts instead of
fitting it together in one. Only for simplification? I don't think that
it's getting easier if it is split and with the rules of old DeMorgan you
can simplify also rather complex conditions to readable ones.
But I see now, that was not the idea.
Thanks!
Gerhard
>>
>> That is simply not possible with where, because "where" with all
>> his "also's" subsets the input-data. It doesn't matter were it is
located
>> in the step. It is always active on the at the dataset in the
>> parameter "data=sashelp.class". It's the same as the dataset option
>> (where=...) in that option like
>>
>> ... data=sashelp.class(where=(sex='F' and ....)) ...
>>
>>
>>
>>
>>
>>
>> >
>> >Or where you referring to WHERE ALSO.
>> >
>> >>
>> >> Our SAS-L Rookie nominations, with Karma, Joe Matise, and Akshaya all
>> seem to have
>> >> great depth to them, which is great!
>> >
>> >New to SAS-L don't necessarly mean new to SAS.
>> >>
>> >> Mary Howard
>> >>
>> >> ----- Original Message -----
>> >> From: karma
>> >> To: SAS-L@LISTSERV.UGA.EDU
>> >> Sent: Wednesday, February 11, 2009 8:21 AM
>> >> Subject: Re: Different WHERE statements for different variables?
>> >>
>> >>
>> >> What about the also statement?
>> >>
>> >> Proc summary data=sashelp.class mean print;
>> >> where sex='F'; var height;
>> >> where also age>14; var weight;
>> >> where also height > 60; var age;
>> >> Run;
>> >>
>> >> log:
>> >>
>> >> NOTE: There were 2 observations read from the data set
SASHELP.CLASS.
>> >> WHERE (sex='F') and (age>14) and (height>60);
>> >>
>> >> 2009/2/11 Akshaya Nathilvar <akshaya.nathilvar@gmail.com>:
>> >> > I don't think so, it's possible in any Data or Proc step, since
SAS
>> always
>> >> > considers the most recent WHERE clause and replace it with the
>> previous
>> >> > defined WHERE clauses:
>> >> > Mean is calculated only based on the final where statement: and a
>> note in
>> >> > log: WHERE clause has been replaced.
>> >> >
>> >> > Proc summary data=sashelp.class mean print;
>> >> > where sex='F'; var height;
>> >> > where age>14; var weight;
>> >> > where height > 60; var age;
>> >> > Run;
>> >> >
>> >> >
>> >> >
>> >> > On Wed, Feb 11, 2009 at 7:55 AM, Gary <gshyoung@gmail.com> wrote:
>> >> >
>> >> >> Hi all,
>> >> >>
>> >> >> I've always wondered, but never gotten to work, whether it is
>> possible
>> >> >> to have different WHERE statements for different variables? For
>> >> >> example, if I run a PROC SUMMARY on variables x, y and z, would
it
>> be
>> >> >> possible to have one WHERE condition apply to x, another to y,
and
>> >> >> another to z? What about a PROC SQL?
>> >> >>
>> >> >> Many thanks,
>> >> >> G.
>> >> >>
>> >> >
>> >>
>>
|