BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
amanda_cz
Calcite | Level 5

I'm try to compute the mean of a variable (A) for its joint industry (X), performance (Y) decile, where the mean excludes the obs itself. I already created deciles for variable Y within each industry X,

but can't figure out how to calculate the mean of each decile excluding the obs. Any suggestions are much appreciated!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Amanda,

I'm assuming that you already know how to compute the mean for each X/Y group, how to save the results as a SAS data set, and how to merge that back into the original data.  (If not, you will have some studying ahead of you.)

Getting the mean excluding the current observation is not very different.  Instead of computing the mean, compute the SUM and N statistics for each X/Y group.  Save the results as a SAS data set.  Merge it back onto the original data.  Using the same step that merges SUM and N back onto the data, add a few statements to calculate the mean.  For example:

MEAN = (SUM - A) / (N - 1);

The programming may be easy or difficult, depending on which parts you already know how to do.

Good luck.

View solution in original post

2 REPLIES 2
Astounding
PROC Star

Amanda,

I'm assuming that you already know how to compute the mean for each X/Y group, how to save the results as a SAS data set, and how to merge that back into the original data.  (If not, you will have some studying ahead of you.)

Getting the mean excluding the current observation is not very different.  Instead of computing the mean, compute the SUM and N statistics for each X/Y group.  Save the results as a SAS data set.  Merge it back onto the original data.  Using the same step that merges SUM and N back onto the data, add a few statements to calculate the mean.  For example:

MEAN = (SUM - A) / (N - 1);

The programming may be easy or difficult, depending on which parts you already know how to do.

Good luck.

amanda_cz
Calcite | Level 5

Thanks. It works like a charm!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2619 views
  • 1 like
  • 2 in conversation