hi all,
I have the data from19961/01/01 to 2014/12/31.
Below is part of my data
Date | Mist(1) |
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 |
how can i output the chart like this.
thanks all,
Y
data intermediate;
set have;
pos_neg=sign(mist);
run;
proc summary data=intermediate;
class date pos_neg;
var mist;
format date year4.;
output out=want mean= std= n=/autoname;
run;
This code is untested as we cannot write code to work with data that is a screen capture. In the future, please provide code as working SAS data step code (instructions).
data intermediate;
set have;
pos_neg=sign(mist);
run;
proc summary data=intermediate;
class date pos_neg;
var mist;
format date year4.;
output out=want mean= std= n=/autoname;
run;
This code is untested as we cannot write code to work with data that is a screen capture. In the future, please provide code as working SAS data step code (instructions).
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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.