turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Mean Function help

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

a week ago

im trying to find out column level mean function.

data m;

input name$ var1 var2 var3;

cards;

a 10 0 5

b 1 2 0

c 9 5 8

;run;

proc means data=m nway noprint;

var var1 var2;

output out=rmean;

run;

proc sql;

create table m3 as

select mean(var2) as mean

from m;

quit;

now proc means and proc sql both are giving column wise mean value

but i was trying to use this but why this is not working in data set approach:---

data m2;

set m;

c1=mean(var2);

run;

this is not working plz help me

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to adi121

a week ago

The MEAN function in a DATA step does means across columns within each row, not across rows. Your example then of having one variable inside your MEAN function is pointless as it will just return the value of that column. It is only useful for more than one column.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to adi121

a week ago

in a data step you would have to go back to basics:

```
data m2;
set sashelp.class end=done;
s + weight;
n + (not missing(weight));
if done then do;
mean = s/n;
output;
end;
keep n mean;
run;
```

PG