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

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 770 views
  • 0 likes
  • 2 in conversation