BookmarkSubscribeRSS Feed
Cruise
Ammonite | Level 13

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?

 

supportJan8.png

 

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.  

16 REPLIES 16
snoopy369
Barite | Level 11

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.

Cruise
Ammonite | Level 13
My apology. I meant y-axis. I'm dealing with data that is different by age. so using same scale for all age categories is not making a perfect sense here. hope that makes sense.
snoopy369
Barite | Level 11
That doesn't change my answer other than meaning you should choose UNISCALE=ROW instead of UNISCALE=COLUMN.
Cruise
Ammonite | Level 13

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;

snoopy369
Barite | Level 11
You have UNISCALE=ROW on the SERIES statement, which is wrong.
Yishi-
Calcite | Level 5

It works! Thanks

PeterClemmensen
Tourmaline | Level 20

Don't you mean that you want different scales on your y-axes for different values of your ageat variable?

Cruise
Ammonite | Level 13
hey, yes. y-axis. i just edited my post. thanks!
PeterClemmensen
Tourmaline | Level 20

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?

Cruise
Ammonite | Level 13
Plots on same scale should be kept for reference. Also, it's kids weight and height data where agecat is a modifier. So comparing newborn (agecat=1) to 5 year old kid (agecat=5) is not my primary research question but difference across race groups. Because of interactions, some graphs are collapsed and hard to eyeball,ie., middle three groups of agecat. Would you agree?
snoopy369
Barite | Level 11
I think that the way you have it laid out above, I agree with Draycut; you should not change the column axes. What you should change is the entire presentation.

The reason to have a grid like this is to have the ability to compare left-to-right and up-to-down. So up and down makes sense: you have different races, and you want to be able to see the differences between asian and white or whatever. That's a good idea and makes perfect sense.

However, with the ages left to right, would you want to compare the newborns with the four year olds, by weight? I doubt it: you'd want to compare something *about* them, rather. So chart that. Or normalize your data, so instead of using actual weight/height, you normalize it to the 50th percentile for that age or something like that. But better I think would be to chart what you actually expect people to be looking at here, which I don't think is just the weight/height.
Cruise
Ammonite | Level 13
Sorry for a confusion. This is kids' "weight and height for age percentile data" adjusted to gender. Where I defined obesity to 1 if kids percentile hits 97.7% else 0. And computed the obesity rate as: event count/n of kids in the strata (by age and race). I thought resulting data must be normalized since the source data was a normalized percentile data. isn't it?
snoopy369
Barite | Level 11

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.  

Cruise
Ammonite | Level 13
Thanks snoopy. Thanks for your insight!!! Off topic. Shall I create a separate post on how to output high resolution image out of this program?

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
  • 16 replies
  • 15863 views
  • 6 likes
  • 5 in conversation