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

Hello, again.

 

I need to help, pretty please.

 

I have this data (screenshot only showing a portion):

Capture.JPG

 

And I need to find out: What was the average (mean) dollar spent of females in the 50-59 Age Group? 

 

So my code is written as follows:

proc means data=profoot.pro_football_segments;
    format age age.;
	class dollars_spent age_bracket gender;
	where age_bracket='50s' and gender='female';
run; 

But my log indicates this:

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 61         
 62         proc means data=profoot.pro_football_segments;
 63             format age age.;
 64         class dollars_spent age_bracket gender;
 65         where age_bracket='50s' and gender='female';
 66         run;
 
 NOTE: No observations were selected from data set PROFOOT.PRO_FOOTBALL_SEGMENTS.
 NOTE: There were 0 observations read from the data set PROFOOT.PRO_FOOTBALL_SEGMENTS.
       WHERE (age_bracket='50s') and (gender='female');
 NOTE: PROCEDURE MEANS used (Total process time):
       real time           0.02 seconds
       cpu time            0.01 seconds
       
 
 67         
 68         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 81         

What am I doing incorrect?

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

class dollars_spent age_bracket gender;

 

When you put a variable in the class statement it means to create an analysis for each level of that variable. Do not put dollars_spent on a the class statement.

View solution in original post

8 REPLIES 8
Reeza
Super User

Female not female. 

Case matters in character variables. 

bldudley
Obsidian | Level 7

Thank you so much. I would like to blame sleep deprivation on these little mistakes.

 

One more question: Now that I fixed the capital letter and re-ran the code, I'm getting the following result.

Capture.JPG

 

I need to find the mean dollar spent of females in their 50's. Do you have any guidance to change the table?

 

Thank you, in advance.

ballardw
Super User

Where is case sensitive

 

gender='Female' not gender='female' if I read your example data (that picture has text that is way too small to read easily) correctly.

 

Dollars_spent should be on a VAR statement.

 

Var dollars_spent;

 

 

 

bldudley
Obsidian | Level 7

Thank you. I've corrected per your guidance.

 

I still don't think I have it quite right. I need to find the average dollar spent for the females in 50's. I'm pretty sure I need to have one mean rather than several.

 

my code:

proc means data=profoot.pro_football_segments;
    format age age.;
	class dollars_spent age_bracket gender;
	var dollars_spent;
	where age_bracket='50s' and gender='Female';
run; 

and I get:

Capture.JPG

Reeza
Super User

Although we're happy to answer question please spend some time searching as well. 

 

Good references are available on Lexjansen.com

 

You've figured out using VAR to limit the variable. To limit the statistics shown list the relevant ones in the PROC MEANS statement. You probably want the NWAY option as well. 

 

PROC MEANS .... Mean STD NWAY;

 

bldudley
Obsidian | Level 7

Reeza,

Thank you. I appreciate your time. I'm only asking after trying to research and figure this out. I'm just beginning, so I appreciate everyone's help with this.

ballardw
Super User

class dollars_spent age_bracket gender;

 

When you put a variable in the class statement it means to create an analysis for each level of that variable. Do not put dollars_spent on a the class statement.

bldudley
Obsidian | Level 7

Thank you very much. I appreciate your time and help.

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!

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
  • 8 replies
  • 1796 views
  • 4 likes
  • 3 in conversation