## How to calculate a mean of certain values defined

Occasional Contributor
Posts: 16

# How to calculate a mean of certain values defined

Hi, I have the following values, and I'd like to get a mean for the defined categories of 8 through 18 ONLY. How should I write my code so that I can get the mean values that belong to all that fall in the categories of 8 through 18? Thanks.

PROC FORMAT;

value FGVARS_C

0='Hand motion'

1='Possession of Light'

2='No possession of light'

3='Counting fingers at 1m'

4='Counting fingers at 2m'

5='Counting fingers at 3m'

6='Counting fingers at 4m'

7='Counting fingers at 5m'

8='6 meters'

9='9 meters'

10='9.5 meters'

11='12 meters'

12='15 meters'

13='18 meters'

14='24 meters'

15='30 meters'

16='36 meters'

17='48 meters'

18='60 meters';

run;

PROC Star
Posts: 1,316

## Re: How to calculate a mean of certain values defined

PROC MEANS DATA=have(where=(selectvar between 8 and 18)) MEAN;

VAR analvar;

RUN;

Tom

Posts: 2,125

## Re: How to calculate a mean of certain values defined

If you want the mean for each level of selectvar, add a class statement.

PROC MEANS DATA=have(where=(selectvar between 8 and 18)) MEAN;

CLASS selecvar;

VAR analvar;

RUN;

Doc Muhlbaier

Duke

Occasional Contributor
Posts: 16

## Re: How to calculate a mean of certain values defined

Hi, Duke.

Thanks for your reply. Could you define "analvar" and "selecvar" for me?

Thanks,

GF

Super User
Posts: 23,771

## Re: How to calculate a mean of certain values defined

You didn't provide your variable names, so Tom's used short hand notation, selecvar = select variable - variables used to filter your selection.

analvar is your analysis variable, what you want the summary of.

Between DOES include the boundary values. If it didn't (but it does) you could always just increment/decrease your boundary values (7, 19).

Occasional Contributor
Posts: 16

## Re: How to calculate a mean of certain values defined

Hi, Tom

Thanks for your reply. When we use the WHERE statement with *between* 8 and 18, my understanding is that we're not including the categories 8 and 18. Is there any other way to code so that I can actually include the categories 8 and 18, not just from 9 to 17?

Thanks,

GF

Discussion stats
• 5 replies
• 269 views
• 6 likes
• 4 in conversation