BookmarkSubscribeRSS Feed
epiala
Calcite | Level 5

I am attempting to create a single graph showing the average EMS transports by hospital using Proc SGSCATTER Compare.  Unfortunately, my data on hospitals is ungrouped (each hospital represents its own column) and as such, I cannot seem to find a way to assign a different color to each hospital series.  This is my current syntax but I am aware that this will not work unless my compare statement uses the GROUP option.  Is there any way around this to get the layout I want?  Thanks in advance for any suggestions.

proc template;                                                                                                                         

define style styles.custom;                                                                                                         

parent=styles.default;                                                                                                               

style GraphData1 from GraphData1 /                                                                                                 

contrastcolor=purple ;                                                                            

style GraphData2 from GraphData2 /                                                                                                 

contrastcolor=orange ;                                                                            

style GraphData3 from GraphData3 /                                                                                                 

contrastcolor=blue ;

style GraphData4 from GraphData4 /                                                                                                 

contrastcolor=red ;                                                                            

style GraphData5 from GraphData5 /                                                                                                 

contrastcolor=green ;                                                                            

style GraphData6 from GraphData6 /                                                                                                 

contrastcolor=black ;

style GraphData7 from GraphData7 /                                                                                                 

contrastcolor=rose ;                                                                            

style GraphData8 from GraphData8 /                                                                                                 

contrastcolor=gray ;                                                                            

style GraphData9 from GraphData9 /                                                                                                 

contrastcolor=yellow ;

end;                                                                                                                                 

ods html file='' style=Custom;

proc sgscatter data=HS.transports;

title "Arrivals Jan. 2011-Dec. 2013";

compare y= (Hosp1 Hosp2 Hosp3 Hosp4 Hosp5 Hosp6 Hosp7 Hosp8 Hosp9 x=servicedate /

     join=(lineattrs=(pattern=solid));run;

ods html close;

2 REPLIES 2
DanH_sas
SAS Super FREQ

For now, you best option is to transpose your data such that you have a column of hospital names and use PROC SGPANEL to create the graph. Here is the SGPANEL code that should give you the result you want:

/* Each cell will have the hospital name */

proc sgpanel data=HS_transports;

panelby hospitals / onepanel;

series x=servicedate y=arrivals / markers lineattrs=(pattern=solid);

run;

- or -

/* Add some color as well */

proc sgpanel data=HS_transports noautolegend;

panelby hospitals / onepanel;

series x=servicedate y=arrivals / markers group=hospitals lineattrs=(pattern=solid);

run;

Hope this helps!

Dan

epiala
Calcite | Level 5

DanH, I can't thank you enough.  This worked beautifully!  Liz

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 2 replies
  • 1079 views
  • 0 likes
  • 2 in conversation