BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
victory
Fluorite | Level 6

hi all,

I have the data from19961/01/01 to 2014/12/31. 

Below is part of my data

DateMist(1)
1996-06-20-0.0027
1996-06-210.0026
1996-06-240.0042
1996-06-250.0045
1996-06-260.0018
1996-06-270.0016
1996-06-28-0.0002
1996-07-010.0027
1996-07-020.0009
1996-07-03-0.0005
1996-07-040.0070

 

how can i output the chart like this.

victory_2-1666883379837.png

 

thanks all,

Y

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
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).

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
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).

--
Paige Miller
Tom
Super User Tom
Super User

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;

Tom_0-1666893517241.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 527 views
  • 5 likes
  • 3 in conversation