BookmarkSubscribeRSS Feed
BingyiYang
Calcite | Level 5

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.

3 REPLIES 3
PGStats
Opal | Level 21

Look at proc hpbin as a faster and more flexible alternative to proc rank.

PG
ballardw
Super User

@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.

BingyiYang
Calcite | Level 5

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. 

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 3 replies
  • 1363 views
  • 0 likes
  • 3 in conversation