Like many, I have data with an outlier. I want a lattice columnaxes with ranges 0-240, 300-340 with a break character. I am unable to specify, since it requires tickvalues.
Can someone guide me? Thank you.
Stan
proc template;
definestatgraph Fig_5_4_3;
dynamic VAR VARLABEL;
begingraph;
entrytitle "&year Widget Contracts ($/unit)" ;
layout lattice / columndatarange=union rowweights=PREFERRED
columndatarange=union rowgutter=2px;
columnaxes;
columnaxis / display=(ticks tickvalues)
label=VARLABEL
labelattrs=(size=10)
linearopts=(tickvalueformat=dollar4. viewmax=340
tickvaluelist=(0 20 40 60 80 100 120 140 160 180 200 220 300 320 340) ) ;
endcolumnaxes;
layout overlay /yaxisopts=(griddisplay=on);
histogram PayerCF / nbins=40 binaxis=false;
densityplot PayerCF / lineattrs=graphfit name='n' legendlabel='Normal';
layoutgridded /columns=2 border=TRUE autoalign=(TopRight);
entry halign=left "N";
entry halign=left eval(strip(put(n(VAR),comma6.)));
entry halign=left "Mean";
entry halign=left eval(strip(put(mean(VAR),dollar6.2)));
entry halign=left "Median";
entry halign=left eval(strip(put(median(VAR),dollar6.2)));
endlayout;
endlayout;
layout overlay / yaxisopts=(griddisplay=on);
boxplot y=PayerCF /orient=horizontal /* boxwidth=.8 */
meanattrs=(color=navy size=10 symbol=diamondfilled)
dataskin=GLOSS
display=(CAPS FILL MEAN MEDIAN )
extreme=true ;
endlayout;
endlayout;
endgraph;
end;
run;
The solution is to NOT define the column axis within layout lattice. Rather, define it exactly the same for both lattice overlays. I turned the display=NONE option for the histogram.
proc template;
define statgraph Fig_5_4_3;
dynamic VAR VARLABEL;
begingraph /DesignWidth=650px;
entrytitle "&year Widget Contracts ($/unit)" ;
layout lattice / columndatarange=union rowweights=(0.8 0.2)
columndatarange=union rowgutter=2px;
layout overlay /yaxisopts=(griddisplay=on)
xaxisopts=(display=NONE linearopts=(includeranges=(0-220 310-330) ) ) ;
histogram PayerCF / nbins=40 binaxis=false;
densityplot PayerCF / lineattrs=graphfit name='n' legendlabel='Normal';
layout gridded /columns=2 border=TRUE autoalign=(TopLeft);
entry halign=left "N";
entry halign=left eval(strip(put(n(VAR),comma6.)));
entry halign=left "Mean";
entry halign=left eval(strip(put(mean(VAR),dollar6.2)));
entry halign=left "Median";
entry halign=left eval(strip(put(median(VAR),dollar6.2)));
endlayout;
endlayout;
layout overlay / yaxisopts=(griddisplay=on)
xaxisopts=(display=(LINE TICKS TICKVALUES)
linearopts=(includeranges=(0-220 310-330) tickvalueformat=dollar4.
tickvaluelist=(0 20 40 60 80 100 120 140 160 180 200 220 320)
) ) ;
boxplot y=PayerCF /orient=horizontal
meanattrs=(color=navy size=10 symbol=diamondfilled)
dataskin=GLOSS
display=(CAPS FILL MEAN MEDIAN )
extreme=true ;
endlayout;
endlayout;
endgraph;
end;
run;
The solution is to NOT define the column axis within layout lattice. Rather, define it exactly the same for both lattice overlays. I turned the display=NONE option for the histogram.
proc template;
define statgraph Fig_5_4_3;
dynamic VAR VARLABEL;
begingraph /DesignWidth=650px;
entrytitle "&year Widget Contracts ($/unit)" ;
layout lattice / columndatarange=union rowweights=(0.8 0.2)
columndatarange=union rowgutter=2px;
layout overlay /yaxisopts=(griddisplay=on)
xaxisopts=(display=NONE linearopts=(includeranges=(0-220 310-330) ) ) ;
histogram PayerCF / nbins=40 binaxis=false;
densityplot PayerCF / lineattrs=graphfit name='n' legendlabel='Normal';
layout gridded /columns=2 border=TRUE autoalign=(TopLeft);
entry halign=left "N";
entry halign=left eval(strip(put(n(VAR),comma6.)));
entry halign=left "Mean";
entry halign=left eval(strip(put(mean(VAR),dollar6.2)));
entry halign=left "Median";
entry halign=left eval(strip(put(median(VAR),dollar6.2)));
endlayout;
endlayout;
layout overlay / yaxisopts=(griddisplay=on)
xaxisopts=(display=(LINE TICKS TICKVALUES)
linearopts=(includeranges=(0-220 310-330) tickvalueformat=dollar4.
tickvaluelist=(0 20 40 60 80 100 120 140 160 180 200 220 320)
) ) ;
boxplot y=PayerCF /orient=horizontal
meanattrs=(color=navy size=10 symbol=diamondfilled)
dataskin=GLOSS
display=(CAPS FILL MEAN MEDIAN )
extreme=true ;
endlayout;
endlayout;
endgraph;
end;
run;
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.