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

Hi, I am trying to find mean by group of my data. I have one indicator variable (named CR) taking value of either 0 or 1. I have another variable of deciles (named decile) taking value from 0 to 9. I am trying to find out the mean of CR within each decile. I did the following:

proc means data= DATA. CR mean;

var CR;

by decile;

run;

quit;

Can you please let me know what am I doing wrong since I am not getting the desired output?

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

The main thing you're doing wrong is not reading the log to see what messages SAS is giving you.  Nobody here can figure that out, so it would be a good idea to post the log.

 

Here's a small list of relevant items to consider:

 

  • You have a space in the middle of DATA. CR where there shouldn't be any spaces
  • Is the name of your data set CR?
  • Is your data set saved permanently?  If so, do you know how to write a LIBNAME statement to refer to the folder where it resides?

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Looks like the code should work. What is wrong with the results? Please be very specific and show us the results so we can see what you are seeing.

--
Paige Miller
sanrim
Calcite | Level 5

Thank you for the reply. I was able to solve the issue by sorting the deciles in ascending order.

Astounding
PROC Star

The main thing you're doing wrong is not reading the log to see what messages SAS is giving you.  Nobody here can figure that out, so it would be a good idea to post the log.

 

Here's a small list of relevant items to consider:

 

  • You have a space in the middle of DATA. CR where there shouldn't be any spaces
  • Is the name of your data set CR?
  • Is your data set saved permanently?  If so, do you know how to write a LIBNAME statement to refer to the folder where it resides?
PeterClemmensen
Tourmaline | Level 20

@sanrim hi and welcome to the SAS Community 🙂

 

Can you post some sample of your data and what you want the desired result to look like? Makes it much easier for you to demonstrate what you mean and much easier for us to provide a usable code answer.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 792 views
  • 0 likes
  • 4 in conversation