I often need to plot out the mean/sum of a continuous variable (Y) against the buckets of another continuous variable (X), by a third grouping variable (Z).
Note that the big datasets are typically huge; it is impractical to scatter plot every point. That's why we need to group X into buckets and calculate bucket means first for the plots.
We can do it by using proc rank on X first then calculate buckets for X and Y. But I am wondering if any SAS plot procs can do this automatically. Thanks.
Look at proc hpbin as a faster and more flexible alternative to proc rank.
@BingyiYang wrote:
I often need to plot out the mean/sum of a continuous variable (Y) against the buckets of another continuous variable (X), by a third grouping variable (Z).
Note that the big datasets are typically huge; it is impractical to scatter plot every point. That's why we need to group X into buckets and calculate bucket means first for the plots.
We can do it by using proc rank on X first then calculate buckets for X and Y. But I am wondering if any SAS plot procs can do this automatically. Thanks.
Without knowing what type of plot or what your data currently looks like it is hard to provide any explicit example.
The SGPLOT HBAR and VBAR plots will do Freq, Mean, Median and Sum statistics for a given Response variable for levels of a group variable. "Bins" from a variable can often be created using a format.
Thanks all for your response. I was wondering if there is a way that SAS would convert numeric X to buckets and then plot out Freq/Mean/Sum of Y against bucket means of X automatically. This is a typical data visualization of Y ~ X when dataset is huge. Thanks.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.