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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.