Data visualization with SAS programming

Creating Statistical (Wilkinson) dot plots in SAS

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Creating Statistical (Wilkinson) dot plots in SAS

Is there a way to create a statistical (Wilkinson) dot plot in SAS? That is, a dot plot with each observation indicated by a dot vs. a dot that represents the frequency of observations for the value. See the example here: https://community.jmp.com/t5/JMP-Blog/JMP-add-in-for-statistical-dot-plots/ba-p/30343. If there's not a built-in option to create a dot plot like this, any suggestions for using GTL to generate something similar?

 

Thanks in advance!

 


Accepted Solutions
Solution
‎12-01-2017 08:40 AM
Super User
Posts: 22,874

Re: Creating Statistical (Wilkinson) dot plots in SAS

Here's a start for you. Definitely needs some customizing.

 


proc sort data=sashelp.class out=class;
    by age;
run;

data class_list;
    set class;
    by age;

    if first.age then
        y=0;
    y + 1;
run;

PROC SGPLOT data=class_list;
    scatter x=age y=y / 
        FILLEDOUTLINEDMARKERS 
        markerattrs=(symbol=circlefilled size=20) 
        markerfillattrs=(color=blue);
        
    yaxis values=(0 to 10 by 2);
run;

quit;

View solution in original post


All Replies
Super User
Posts: 22,874

Re: Creating Statistical (Wilkinson) dot plots in SAS

How 'nice' do you need it to be? I think PROC UNIVARIATE does this but only in the listing output and you need an option to specify it. 

New Contributor
Posts: 2

Re: Creating Statistical (Wilkinson) dot plots in SAS

I'd like it to be nice, ideally nice enough to incorporate into a larger report I output through SAS via ods rtf/pdf.

Super User
Posts: 22,874

Re: Creating Statistical (Wilkinson) dot plots in SAS

Ok, from what I understand, this isn't the same as SAS definition of dot plot - or at least between SAS BASE and JMP which is a little annoying but oh well. 

 

Technically, a dot plot doesn't add any value over a bar chart, but it's ultimately your choice. 

 

I don't see a way to do this easily/automatically so the 'manual' way would be to:

 

1. Use the raw data, sort it by the values you have, so your X. 

2. Create a second variable that can serve as a 'Y' variable which is basically a counter such as 1, 2, 3, 4, 5, 6 - tutorial here

3. Use a SCATTER statement to create the dots - you can use the GROUP options to create the multi colours if desired as well. 

 

It seems relatively straightforward but if you have issues feel free to post back. 

 

 

 

 

Solution
‎12-01-2017 08:40 AM
Super User
Posts: 22,874

Re: Creating Statistical (Wilkinson) dot plots in SAS

Here's a start for you. Definitely needs some customizing.

 


proc sort data=sashelp.class out=class;
    by age;
run;

data class_list;
    set class;
    by age;

    if first.age then
        y=0;
    y + 1;
run;

PROC SGPLOT data=class_list;
    scatter x=age y=y / 
        FILLEDOUTLINEDMARKERS 
        markerattrs=(symbol=circlefilled size=20) 
        markerfillattrs=(color=blue);
        
    yaxis values=(0 to 10 by 2);
run;

quit;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 236 views
  • 0 likes
  • 2 in conversation