hi, Im looking for box plot for 3 group variables one with respect to the right handside y axis and other two to the left y axis.My code below doent give any error, but is not giivng any boxes. It creates a graphic area with default legends but not he boxes. what could be the issue/ can anyone help? Thanks
/*** read in adis and adlb data and combining ***/
proc sort data=analysis.adis(where=( paramcd in ('SAAVTSI') and avisitn>=0 and AVAL ne . )) out=adis(keep= usubjid subjid studyid paramcd param avisit avisitn aval ady rename=(aval=SAAVTSI ady=isdy));
by studyid usubjid subjid avisitn ;
run;
proc sort data=analysis.adlb(where=( paramcd in ('ALTSI' 'ASTSI') and avisitn>=0 and aval ne . )) out=adlb(keep= usubjid subjid studyid avisit avisitn paramcd param anrhi aval ady rename=(ady=lbdy aval=lbaval));
by studyid usubjid subjid avisitn ;
run;
data ip;
set adis(in=a) adlb(in=b);
if lbaval ne . then do;aval1=lbaval/anrhi;end;
else do;aval2=SAAVTSI;end;
if avisitn=0 then visx=0;
else visx=input(scan(avisit,2,''),best.);
/** jitter applies to ALT ***/
if paramcd='ALTSI' then vis=visx-0.15;
/** jitter applies to AST ***/
if paramcd='ASTSI' then vis=visx+0.15;
/** jitter applies to AAV9 ***/
if paramcd='SAAVTSI' then vis=visx+0.05;
param2=param;
param1=param;
/*if paramcd='SAAVTSI' then do;param1=param;param='z';end;
else do;param1="x";end;*/
run;
/*height=8cm width=22.0cm*/
ods graphics on / reset=all height=9.5cm width=21.0cm border=off outputfmt=png;
proc sort data=ip;by paramcd avisitn vis;run;
proc sgplot data=ip dattrmap=myattr;
vbox aval1 / category=vis group=param1 nomean nooutliers whiskerpct=25 connect=median lineattrs=( pattern=1) attrid=param1;
vbox aval2 / category=vis group=param2 y2axis nomean whiskerpct=25 connect=median ;
yaxis label='AAA value' values=(0 to 3 by 0.5) valueattrs=(size=8);
y2axis label='ZZZ titer' TYPE=LOG LOGBASE=2 ;*valueattrs=(size=8) values=(&y2vals. ) valuesformat=best. valuesdisplay=(&y2disp. );
xaxis label='Analysis visit' values=(0,1,2,3,4,6,8,10,12,16,20,24,28,32,36,40,44,48,52 ) valuesdisplay=('Baseline' 'Week 1' 'Week 2' 'Week 3' 'Week 4' 'Week 6' 'Week 8' 'Week 10' 'Week 12' 'Week 16' 'Week 20' 'Week 24' 'Week 28' 'Week 32' 'Week 36' 'Week 40' 'Week 44' 'Week 48' 'Week 52' ) fitpolicy=rotate valuesrotate=diagonal valueattrs=(size=8);
run;
ods graphics off;
I noticed the LOG axis request. Are all of the values of "aval2" greater than zero?
Are the axes showing values? It might be helpfully to see a image of your output.
indeed i have a line plot with the same data and have given the axes values as per that. but even if I leave the axes values with the default, i dont get the boxes !
What version of SAS are you using?
I made up this little test at 9.4.m7 and it seems to work. Can you try it and see if it works for you?
proc sgplot data=sashelp.heart;
vbox cholesterol / category=ageatstart group=weight_status;
vbox cholesterol / category=ageatstart group=weight_status y2axis;
y2axis type=log logbase=2;
run;
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.
Ready to level-up your skills? Choose your own adventure.