09-21-2015 12:23 AM
I have a data looking roughly like this:
Group: G1 / G2
I want to plot the proportion of the event (proportion of 1's) for each group, by age bin. I though to put the age bins on the x-axis, the proportion on the y-axis, and for each age bin, to plot twp points, maybe with different shapes of markers, one for each group, and then I can see what happens to the difference between the groups when the age changes.
1. How do I do that ? The data I specified is my variables as they are. I guess I need sgplots, but not sure how to do this task, it doesn't look straightforward.
2. Is there a better representation that can suit my data ?
Thank you in advance !
09-21-2015 10:48 AM
Perhaps pre-summarize your data, and create a grouped bar chart, something like this?
09-21-2015 02:21 PM
You can run PROC MEANS or some other procedure to get the proportions for each group and for each age group.
Then you can just use the SCATTER statement to plot the proportions against the age, using the GROUP= option to distinguish the groups.
/* make up some data */ data Have; set sashelp.class sashelp.class sashelp.class; event = rand("bernoulli", logistic(1 - age/10)); run; /* compute proportion for each age group and group */ proc means data=Have; class sex age; var event; output out=out mean=Proportion; run; proc sgplot data=out; WHERE _TYPE_=3; scatter y=proportion x=age / group=sex; run;