I'd like use multiple scales on y-axis using below max min values.
agecat1 max= 12 min=3; agecat2 max=20 min=6, agecat3 max=20 min=5 agecat4 max=24 min=8; agecat5 max=27, min=7.
Could you please help modify the code below for multiple scales?
proc sort data=data; by race agecat cat year; run;
ods graphics / height=2000 width=3000;
proc sgpanel data=data;
panelby race agecat/novarname onepanel LAYOUT=panel columns=5 ROWHEADERPOS=right COLHEADERPOS=bottom;
series y=rate x=year / group=cat lineattrs=(pattern=solid);
keylegend/title="legend title" position=bottom;
colaxis label='column title' fitpolicy=thin valuesformat=best4.0 values=(2002 to 2018 by 2);
rowaxis label='rowtitle' grid max=27.0;
title "title";
run;
using SAS 9.4.
It's a bit hard to understand your question; but if you're asking how to make the X axis have different scales, you can use the option on the PANELBY statement UNISCALE which lets you choose between having all column axes the same but row axes different, or all row axes the same and column axes different (this is what you want), or both the same.
Snoopy:
Do you know why I get error below?
4984 ods graphics / height=1500 width=4000;
4985 proc sgpanel data=r.all_cnt;
4986 panelby race ageyears/novarname onepanel LAYOUT=panel columns=5 ROWHEADERPOS=right
4986! COLHEADERPOS=bottom uniscale=row;
4987 series y=pr_obs x=year / group=bf lineattrs=(pattern=solid) uniscale=row;
--------
22
76
ERROR 22-322: Syntax error, expecting one of the following: ;, ATTRID, BREAK, CLUSTERWIDTH,
CURVELABEL, CURVELABELATTRS, CURVELABELPOS, DATALABEL, DATALABELATTRS,
DATALABELPOS, DISCRETEOFFSET, FILLEDOUTLINEDMARKERS, GROUP, GROUPDISPLAY,
GROUPORDER, LEGENDLABEL, LINEATTRS, MARKERATTRS, MARKERFILLATTRS,
MARKEROUTLINEATTRS, MARKERS, NAME, NOMISSINGGROUP, SMOOTHCONNECT, SPLITCHAR,
SPLITCHARNODROP, SPLITJUSTIFY, TIP, TIPFORMAT, TIPLABEL, TRANSPARENCY, URL.
ERROR 76-322: Syntax error, statement will be ignored.
4988 keylegend/title="BREASTFEEDING DURATION" position=bottom;
4989 format race race. ageyears ageyears. bf bf.;
4990 colaxis label='COHORT YEARS' fitpolicy=thin valuesformat=best4.0 values=(2002 to 2015 by 1);
4991 rowaxis label='PREVALENCE OF OBESITY' grid max=27.0;
4992 title "OBESITY PREVALENCE BY";
4993 run;
It works! Thanks
Don't you mean that you want different scales on your y-axes for different values of your ageat variable?
Ok. My first question is: why?
Usually you create a panel of graphs like this to be able to quickly compare characteristics of different group sin your data (in your example age and race). This comparability is worsened if you do not have the same values on your axes?
And this is why it's helpful to give complete information in your question.
If you're normalizing it to age percentile, then why do you want to adjust the row axes? I think you should not alter the row axes for the different ages if it's adjusted by percentile: your chart is, correctly, showing that different age ranges have a different prevalence of obesity.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.