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;
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.
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.
Female not female.
Case matters in character 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?
Thank you, in advance.
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;
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:
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;
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.
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.
Thank you very much. I appreciate your time and help.
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!
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.