BookmarkSubscribeRSS Feed
RVA
Fluorite | Level 6 RVA
Fluorite | Level 6

I wanted to produce a bar graph as the following (graph 1).  You can see that on the horizontal axis, the "student_class" variable is nested into the "seen_notseen" variable.  However, I could not figure out how to do this.  The only thing I could do was produce two separate graphs, one for "seen" students and one for "notseen" students (see graphs 2a and 2b).  Do you have any ideas on how I can produce a graph that looks like g

Graph 1:

SKM_C364e15031915030_0001.jpg

Graphs 2a and 2b:


SKM_C364e15031915140_0001.jpg

SKM_C364e15031915141_0001.jpg

Below are the codes I used to produce graph 2a (and 2b):

/* Set the graphics environment */                                                                                               
goptions reset=all cback=white border htitle=15pt htext=12pt;                                                                    
                                                                                                                                                                                                                                                                        
/* Define the axis characteristics */                                                                                             
axis1 value=none label=none;                                                                                                   
axis2 label=(angle=90 'Number of Students');                                                                                         
axis3 label=none;                                                                                                              
/* Define the legend options */                                                                                                  
legend1 frame label=none;                                                                                                                 

/* Generate the graph */                                                                                                         
title1 'Academic Standing by Class (Seen Students)';                                                                                    

proc gchart data=students_b;

where class in ('FR','SO','JR','SR') and acadstanding not in (' ','N/A') and meetingcount > 0;

format acadstanding $standing_b. class $class_b.;

vbar acadstanding /

subgroup=acadstanding group=class type=freq                                                                    
legend=legend1 space=0 gspace=4 width=5                                                                              
maxis=axis1 raxis=axis2 gaxis=axis3;                                                                            
run;                                                                                                                             
quit;
4 REPLIES 4
DanH_sas
SAS Super FREQ

I'm not sure of your SAS version, but you can use PROC SGPANEL create this chart. Below is a similar example. If you want the headers are the bottom, use COLHEADERPOS=BOTTOM on the PANELBY statement. Hope this helps!

proc sgpanel data=sashelp.heart;

panelby sex / novarname layout=columnlattice onepanel;

vbar weight_status / response=cholesterol stat=mean group=bp_status

     groupdisplay=cluster;

run;

SGPanel.png

RVA
Fluorite | Level 6 RVA
Fluorite | Level 6

Many thanks, Dan.  Unfortunately, I am still running SAS 9.2, so the groupdisplay= option is not available; otherwise, it would be perfect.  Do you have any work-around for me?  Thank you.

DanH_sas
SAS Super FREQ

Unfortunately, no. I had another way to approach it using overlays and DISCRETEOFFSET, but that approach requires at least SAS 9.3. Do you have access to a more recent version of SAS?

RVA
Fluorite | Level 6 RVA
Fluorite | Level 6

Thank you Dan.  Let me ask the IT for an upgrade and will get back to you later.  Thank you.

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
  • 1344 views
  • 4 likes
  • 2 in conversation