BookmarkSubscribeRSS Feed
sms1891
Quartz | Level 8

Hi experts,

I generated an output using SGpanel, however for my y-axis variable (Enrollment_Year 2017, 2018, 2019, 2020, 2021, 2022), the graph output is giving me labeling only for even years and skipping out odd year labeling on the graph. 

 

Thank you for your help in advance!

proc means data=bar1 noprint nway;
 class measure Enrollment_year ;
 var score ;
 where score >.;
 output out=bytype (drop=_type_ _freq_) n(score)=n mean(score )=mean  uclm(score)=uclm lclm(score )=lclm;
 run;  

* also make an overall graph;
proc means data=bar1 noprint nway;
 class Enrollment_year   ;
 var score ;
 where score >.;
 output out=bytypeall (drop=_type_ _freq_) n(score)=n  mean(score )=mean  uclm(score)=uclm lclm(score )=lclm;
 run;  
 data bytypeall; set bytypeall;
  measure="OVERALL"; 
  run;  
 

data bytype2; set bytype bytypeall;
 Activity=measure; * just renaming;
  
  meanround=round(mean,.1); format meanround 4.1;
  group=measure ||' '||  Enrollment_year || '  '||(put(n,$3.))||'  '||put(meanround,f4.1) ;

  typen=  Enrollment_year  || '  '||(put(n,$3.))||'  '||put(meanround,f4.1) ;
  labelatzero=.01;
  labelatzero2='N = '||(put(n,$3.));
  *if activity='OVERALL' then labelatzero2=' ';

run; 

title 'Dont use this plot because there are not enough practices in act 1 to 10 in early years';
* the problem with sgpanel is the number of graphs to look at is uneven and height cant be specified - ah - can change height though!;
ods graphics on /  border=off height=10in width=8in noscale outputfmt=png ;
proc sgpanel data=bytype2 ; 
 panelby Activity/ layout=panel border /*noheaderborder*/ columns=2 rows=8  skipemptycells /*onepanel*/ 
         headerbackcolor=lightgrey headerattrs=(family=arial size=9 weight=bold color=black);
 highlow y=Enrollment_year   high=uclm low=lclm/ type=bar barwidth=.5 nooutline fillattrs=(color=cx42A5F5)  transparency=.3
       name='bar' legendlabel='95% Confidence Interval';
 scatter y=Enrollment_year    x=mean/Markerattrs=( Symbol=CIRCLEFILLED color=black Size=12) NAME="dot" legendlabel='Mean'; 
   colaxis label='Score' min=0 max=4 values=(0 1 2 3 4) labelattrs=(family=arial size=10 weight=bold color=black); 
   rowaxis label='Enrollment Year' labelattrs=(family=arial size=8 weight=bold color=black) REVERSE ; 
   text y=Enrollment_year  x=labelatzero text= labelatzero2;
   keylegend 'dot' 'bar';
 run; 

 

2 REPLIES 2
ballardw
Super User

Add a VALUES= list of values to your Rowaxis statement.

   rowaxis label='Enrollment Year' labelattrs=(family=arial size=8 weight=bold color=black) values=(2017 to 2022 by 1) REVERSE ; 

@sms1891 wrote:

Hi experts,

I generated an output using SGpanel, however for my y-axis variable (Enrollment_Year 2017, 2018, 2019, 2020, 2021, 2022), the graph output is giving me labeling only for even years and skipping out odd year labeling on the graph. 

 

Thank you for your help in advance!

proc means data=bar1 noprint nway;
 class measure Enrollment_year ;
 var score ;
 where score >.;
 output out=bytype (drop=_type_ _freq_) n(score)=n mean(score )=mean  uclm(score)=uclm lclm(score )=lclm;
 run;  

* also make an overall graph;
proc means data=bar1 noprint nway;
 class Enrollment_year   ;
 var score ;
 where score >.;
 output out=bytypeall (drop=_type_ _freq_) n(score)=n  mean(score )=mean  uclm(score)=uclm lclm(score )=lclm;
 run;  
 data bytypeall; set bytypeall;
  measure="OVERALL"; 
  run;  
 

data bytype2; set bytype bytypeall;
 Activity=measure; * just renaming;
  
  meanround=round(mean,.1); format meanround 4.1;
  group=measure ||' '||  Enrollment_year || '  '||(put(n,$3.))||'  '||put(meanround,f4.1) ;

  typen=  Enrollment_year  || '  '||(put(n,$3.))||'  '||put(meanround,f4.1) ;
  labelatzero=.01;
  labelatzero2='N = '||(put(n,$3.));
  *if activity='OVERALL' then labelatzero2=' ';

run; 

title 'Dont use this plot because there are not enough practices in act 1 to 10 in early years';
* the problem with sgpanel is the number of graphs to look at is uneven and height cant be specified - ah - can change height though!;
ods graphics on /  border=off height=10in width=8in noscale outputfmt=png ;
proc sgpanel data=bytype2 ; 
 panelby Activity/ layout=panel border /*noheaderborder*/ columns=2 rows=8  skipemptycells /*onepanel*/ 
         headerbackcolor=lightgrey headerattrs=(family=arial size=9 weight=bold color=black);
 highlow y=Enrollment_year   high=uclm low=lclm/ type=bar barwidth=.5 nooutline fillattrs=(color=cx42A5F5)  transparency=.3
       name='bar' legendlabel='95% Confidence Interval';
 scatter y=Enrollment_year    x=mean/Markerattrs=( Symbol=CIRCLEFILLED color=black Size=12) NAME="dot" legendlabel='Mean'; 
   colaxis label='Score' min=0 max=4 values=(0 1 2 3 4) labelattrs=(family=arial size=10 weight=bold color=black); 
   rowaxis label='Enrollment Year' labelattrs=(family=arial size=8 weight=bold color=black) REVERSE ; 
   text y=Enrollment_year  x=labelatzero text= labelatzero2;
   keylegend 'dot' 'bar';
 run; 

 


 

sms1891
Quartz | Level 8

Thank you for the response. Tried rowaxis label='Enrollment Year' labelattrs=(family=arial size=10 weight=bold color=black) values=(2017 to 2022 by 1) REVERSE ;  

 

Still not working.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 509 views
  • 0 likes
  • 2 in conversation