BookmarkSubscribeRSS Feed
viollete
Calcite | Level 5

Hi,

 

I want to draw a simple quadrant graph in SAS. The example of the data is:

 

Hospital_name  death_rate_2013 diff_compare_with_2015

AA1  1.2  -0.5

AA2  1.5   0.1

AA3  0.8   0

AA4  1.0  -0.4

AA5  1.9   0.4

AA6  1.4   0.1

AA7  0.5  -0.2

 

I want the horizontal axis be: Low death rate (on the left) and high death rate (on the right)

Vertical axis: Low reduction (bottom) and high reduction (top)

 

And in the graph to show where each hospital is placed. How can I do it?

 

Thanks

5 REPLIES 5
Rick_SAS
SAS Super FREQ

It sounds like you want a basic scatter plot with markers labeled by the hospital name:

 

data Have;
input Hospital_name $3. death_rate_2013 diff_compare_with_2015;
datalines;
AA1  1.2  -0.5
AA2  1.5   0.1
AA3  0.8   0
AA4  1.0  -0.4
AA5  1.9   0.4
AA6  1.4   0.1
AA7  0.5  -0.2
;

proc sgplot data=Have;
scatter x=death_rate_2013 y=diff_compare_with_2015 / datalabel=Hospital_name;
run;

For more about creating simple graphs in SAS, see the SGPLOT documentation. Click the link for the SCATTER statement to learn more about options that are available for scatter plots.

viollete
Calcite | Level 5

No. I would like something similar to the image from here:

 

http://www.prescientdigital.com/articles/intranet-articles/the-big-deal-about-portals

 

Rick_SAS
SAS Super FREQ

It is not clear what features of that graph are important, but try the following:

 

data Have;
input Hospital_name $3. death_rate_2013 diff_compare_with_2015;
datalines;
AA1  1.2  -0.5
AA2  1.5   0.1
AA3  0.8   0
AA4  1.0  -0.4
AA5  1.9   0.4
AA6  1.4   0.1
AA7  0.5  -0.2
;

proc means data=Have mean;
var death_rate_2013;    /* use mean value for reference line */
run;

proc sgplot data=Have noborder;
text x=death_rate_2013 y=diff_compare_with_2015 text=Hospital_name;
refline 1.1857143  / axis=x;   /* use mean value (?) */
refline 0 / axis=y;
xaxis display=(noline noticks novalues);
yaxis display=(noline noticks novalues);
run;
viollete
Calcite | Level 5

Thanks!

 

Just one more question. I would like to make more like this (would like to ut labels into the graph):

 

http://support.sas.com/kb/24/927.html

 

 

DanH_sas
SAS Super FREQ

I'm assuming your talking about the quandrant labels. The easiest way for you to do that is to use INSET statements. To see how this would work, take the code Rick provided and add the following to the SGPLOT procedure:

 

inset "TopLeft" / position=topleft;

inset "Top" / position=top;

inset "TopRight" / position=topright;

inset "Right" / position=right;

inset "BottomRight" / position=bottomright;

inset "Bottom" / position=bottom;

inset "BottomLeft" / position=Bottomleft;

inset "Left" / position=left;

 

If you want the text split onto multiple lines, just break the text using multiple quoted strings:

 

inset "Bottom" "Right" / position=bottomright;

 

Hope this helps!

Dan

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 1863 views
  • 4 likes
  • 3 in conversation