Seems simple enough. What out for testing for negative. Missing values are considered smaller than any actual value.
Also you did not say which group should include the zeros, so I made them their own group. You did not say whether or not you wanted NOBS to count the missing values or not. I decided to exclude them.
data have;
input date :yymmdd. mist ;
cards;
1996-06-20 -0.0027
1996-06-21 0.0026
1996-06-24 0.0042
1996-06-25 0.0045
1996-06-26 0.0018
1996-06-27 0.0016
1996-06-28 -0.0002
1996-07-01 0.0027
1996-07-02 0.0009
1996-07-03 -0.0005
1996-07-04 0.0070
;
proc sql ;
create table want as
select year(date) as year
, mean(mist) as mean
, std(mist) as sd
, sum(mist>0) as positive
, sum(not (mist>=0)) as negative
, mean(case when (mist>0) then mist end) as mean_postive
, mean(case when (mist>0) then . else mist end) as mean_negative
, count(mist) as nobs
, sum(mist=0) as zero
, nmiss(mist) as missing
from have
group by year
;
quit;
proc print;
run;
... View more