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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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