|
On Sun, 5 Mar 2006 09:13:56 -0800, nichas <sachin.gadkar@GMAIL.COM> wrote:
>this sql code also gives you the dataset means which contains the
>required mean of the data given by you.
>
>data one;
> input id return;
>datalines;
>1 0.64336
>1 0.75877
>1 0.53997
>1 0.75732
>1 0.82422
>1 0.61018
>1 0.8767
>10001 0.62921
>10001 0.4848
>10001 0.6444
>10001 0.73933
>10001 0.598
>10001 0.64459
>2001 0.58357
>2001 0.57786
>2001 0.68543
>2001 0.06881
>2001 0.61868
>2001 0.54126
>2001 0.65157
>;
>run;
>
>proc sql noprint;
> create table means as
> select id, sum(return)/count(id) as mean
Why construct this formula instead of simply using the MEAN function? If
there are missing values of RETURN, it will implicitly treat them as
zeroes, which is probably not desirable. If such treatment is appropriate,
better to explicate with a CASE structure.
> from one
> group by id;
>quit;
|