## Frequency Table Issue with Multiple variables

Solved
Occasional Contributor
Posts: 17

# Frequency Table Issue with Multiple variables

Hello, again.

I need to help, pretty please.

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

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; ``````

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

Accepted Solutions
Solution
‎04-18-2017 04:45 PM
Super User
Posts: 13,514

## Re: Frequency Table Issue with Multiple variables

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.

All Replies
Super User
Posts: 23,688

## Re: Frequency Table Issue with Multiple variables

Female not female.

Case matters in character variables.

Occasional Contributor
Posts: 17

## Re: Frequency Table Issue with Multiple variables

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.

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

Super User
Posts: 13,514

## Re: Frequency Table Issue with Multiple variables

[ Edited ]

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;

Occasional Contributor
Posts: 17

## Re: Frequency Table Issue with Multiple variables

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:

Super User
Posts: 23,688

## Re: Frequency Table Issue with Multiple variables

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;

Occasional Contributor
Posts: 17

## Re: Frequency Table Issue with Multiple variables

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.

Solution
‎04-18-2017 04:45 PM
Super User
Posts: 13,514

## Re: Frequency Table Issue with Multiple variables

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.

Occasional Contributor
Posts: 17

## Re: Frequency Table Issue with Multiple variables

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

☑ This topic is solved.