BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
afell89
Calcite | Level 5

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

4 REPLIES 4
Reeza
Super User

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. 

afell89
Calcite | Level 5

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

Reeza
Super User

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. 

 

 

 

 

Reeza
Super User

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;

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
  • 4 replies
  • 1962 views
  • 0 likes
  • 2 in conversation