The orientation of the label in proc sgplot is vertical. How can I change the label into horizontal?
proc sgplot data = baseline; histogram salary/datalabel; density salary; density salary/type= kernal; keylegend / location=inside position=topright; run;
It is real uneasy. Maybe somebody could point you a simple solution.
ods select none;
ods output sgplot=sgplot;
proc sgplot data = sashelp.heart;
histogram weight/datalabel ;
density weight;
density weight/type= kernel;
keylegend / location=inside position=topright;
run;
ods select all;
data a;
set sgplot;
_BIN_WEIGHT_DATALABELTYPE=BIN_WEIGHT_DATALABELTYPE_Auto__Y+0.5;
if not missing( BIN_WEIGHT_DATALABELTYPE_Auto__X );
keep BIN_WEIGHT_DATALABELTYPE_Auto__X BIN_WEIGHT_DATALABELTYPE_Auto__Y BIN_WEIGHT_DATALABELTYPE_Auto_DL
_BIN_WEIGHT_DATALABELTYPE;
format BIN_WEIGHT_DATALABELTYPE_Auto_DL 8.2;
run;
data b;
set sgplot;
if not missing(NORMLD_WEIGHT___X);
keep NORMLD_WEIGHT___X NORMLD_WEIGHT___Y;
run;
data c;
set sgplot;
if not missing(KERNEL_WEIGHT___X) ;
keep KERNEL_WEIGHT___X KERNEL_WEIGHT___Y;
run;
proc sql;
create table temp as
select a.*,NORMLD_WEIGHT___Y
from a,b
group by BIN_WEIGHT_DATALABELTYPE_Auto__X
having abs(BIN_WEIGHT_DATALABELTYPE_Auto__X-NORMLD_WEIGHT___X) =
min(abs(BIN_WEIGHT_DATALABELTYPE_Auto__X-NORMLD_WEIGHT___X));
create table have as
select temp.*,KERNEL_WEIGHT___Y
from temp,c
group by BIN_WEIGHT_DATALABELTYPE_Auto__X
having abs(BIN_WEIGHT_DATALABELTYPE_Auto__X-KERNEL_WEIGHT___X) =
min(abs(BIN_WEIGHT_DATALABELTYPE_Auto__X-KERNEL_WEIGHT___X));
quit;
proc sgplot data=have;
vbarparm category= BIN_WEIGHT_DATALABELTYPE_Auto__X response=BIN_WEIGHT_DATALABELTYPE_Auto__Y / barwidth=1 ;
scatter x=BIN_WEIGHT_DATALABELTYPE_Auto__X y=_BIN_WEIGHT_DATALABELTYPE/
markerchar=BIN_WEIGHT_DATALABELTYPE_Auto_DL discreteoffset=-0.1 ;
series x= BIN_WEIGHT_DATALABELTYPE_Auto__X y=NORMLD_WEIGHT___Y /
name='normal' legendlabel='Normal' smoothconnect lineattrs=graphdata1(thickness=3);
series x= BIN_WEIGHT_DATALABELTYPE_Auto__X y=KERNEL_WEIGHT___Y /
name='kernel' legendlabel='Kernel' smoothconnect lineattrs=graphdata2(thickness=3);
keylegend 'normal' 'kernel'/position=ne location=inside;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.