ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Dcicantab5
Obsidian | Level 7

I am on SAS studio,

trying to create a mean with SE bars over time ( hand hygiene compliance over time, 2 groups of wards ('0' composed of 6 wards with low bed occupancy rates and '1' composed of wards with high occupancy rates).

 

I referred to 

Sample 42542: Plot means with standard error bars from calculated data with PROC SGPLOT

 

Supposed to get 2 pairs of dots & 2 lines with error bars. Didn't happen:

 

undefined

Where did it go wrong?

 

my codes:

proc means data=WORK.HANDHYGIENE3 mean stderr;

class grouphh month;

var findings;

output out=out1hh mean = mean stderr=stderr;

run;

data reshape(drop=stderr);                                                                                                              

   set out1hh;                                                                                                                        

   lower=mean - stderr;                                                                                                                 

   upper=mean + stderr;                                                                                                                 

run;                                                                                                                                    

                                                                                                                                            

ods listing close;                                                                                                                      

                                                                   

ods graphics / reset width=600px height=400px imagefmt=gif;                                                                             

                                                                                                                                        

proc sgplot data=reshape noautolegend;                                                                                                  

   scatter x=month y=mean / yerrorlower=lower                                                                                            

                           yerrorupper=upper                                                                                            

                           markerattrs=(color=blue symbol=CircleFilled);                                                                

   series x=month y=mean / lineattrs=(color=blue pattern=2);                                                                             

   title1 'Plot Means with Standard Error Bars from Calculated Data';                                                                   

run;       

1 ACCEPTED SOLUTION

Accepted Solutions
jklaverstijn
Rhodochrosite | Level 12

Maybe you need to group the series by grouphh:

 

series x=month y=mean / lineattrs=(color=blue pattern=2) group=grouphh;

That worked for me.

 

Regards,

- Jan.

View solution in original post

4 REPLIES 4
jklaverstijn
Rhodochrosite | Level 12

Proc means will calculate stats for all permutations of the classification variables. Add the NWAY option to only keep the grouphh*month interactions. That will take care of the erratic lines in your plot.

 

proc means data=WORK.HANDHYGIENE3 mean stderr nway;

Hope this helps,

- Jan,

jklaverstijn
Rhodochrosite | Level 12

Maybe you need to group the series by grouphh:

 

series x=month y=mean / lineattrs=(color=blue pattern=2) group=grouphh;

That worked for me.

 

Regards,

- Jan.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1914 views
  • 2 likes
  • 2 in conversation