Data visualization with SAS programming

Create scatter plot with quadrants

Posts: 35

Create scatter plot with quadrants



I would like to create a visual aid for my data in order to help me understand outliers. 


What I would like to do is compare values obtained from a survey with values from other sources to see if there is a mismatch and where. 


I was thinking of creating a scatter plot and divding it into four sectors.


My X-axis would be survey values and Y would be Other values.


Therefore the top left would be low survey value high other value, top right high survey value, high admin value and so on.


I've seen such an example for proc gplot bubble graph but I can't seem to replicate it for a scatter graph. Could anyone provide some assitance please?


Here is some sample data for people to look at.


data sample;                                                                                                                          
   input id $ 2. survey other;                                                                                                 
01     15000 65000                                                                                                        
02 6500     6500                                                                                                       
03   8426 10000                                                                                                      
04      1650   16805                                                                                                       
05 630               1500                                                                                         
06  110055           56812                                                                                            
07     24568           15200                                                                                             
08   6000  7800                                                                                                        
Posts: 3,415

Re: Create scatter plot with quadrants

[ Edited ]

You don't mention how you intend to determine the cutoff values, but if you are looking at a regression context, you can look at the ROBUSTREG procedure, which automatically detects points of high-leverage and outliers. See the doc for the robust distance plot, which you can create as follows:


proc robustreg data=sample method=MM plots(only)=rdplot;
model other =survey;

If you have your own method, you can use the REFLINE statement to add vertical and horizontal lines to your scatter plot:


proc sgplot data=sample;
scatter x=survey y=other;
refline 22400 / axis=x;
refline 20000 / axis=y;


Posts: 35

Re: Create scatter plot with quadrants

Rick when I try to run the following command I get the following error.



ods graphics on;
22         proc robustreg data=varsofimport method=MM plots(only)=rdplot;
ERROR: Library COMMON does not exist.
ERROR: Library COMMON does not exist.
WARNING: Unable to load prototypes from 'common.funcs'.
23         model nat_totinc =nat_totinc_admin;
24         run;
Posts: 3,415

Re: Create scatter plot with quadrants

1. What version of SAS?

2. What SAS interface? (Enterprise Guide? SAS Studio? SAS University Edition?)

3. Can you run the Getting Started example in the ROBUSTREG documentation?  

Ask a Question
Discussion stats
  • 3 replies
  • 2 in conversation