## sum of column

Solved
Frequent Contributor
Posts: 126

# sum of column

I want to sum the observations of a column.

A

1

2

6

3

=

Total 12

Accepted Solutions
Solution
‎08-26-2014 09:51 AM
Posts: 1,270

## Re: sum of column

proc sql;
create table want as
select sum(a=1)/count(a) as positive_alpha from have;
quit;

proc print data=want;
run;

All Replies
Posts: 1,270

## Re: sum of column

proc print data=have;

sum a;

run;

Frequent Contributor
Posts: 126

## Re: sum of column

where is the output?

Posts: 1,270

## Re: sum of column

May be I missed something in understanding your problem. What are you trying to do?

Frequent Contributor
Posts: 126

## Re: sum of column

I want to calculate the proportions of positive alphas. So the number in my column are (0,1)

For example,

A

1

0

1

0

so, the proportion of positive alphas is equal to sum of A /number of observations(which is 4 here)=2/4

Solution
‎08-26-2014 09:51 AM
Posts: 1,270

## Re: sum of column

proc sql;
create table want as
select sum(a=1)/count(a) as positive_alpha from have;
quit;

proc print data=want;
run;

Super User
Posts: 10,209

## Re: sum of column

simplest solution, IMO:

proc sql;

/* create table want as */

select sum(a) from have;

quit;

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
🔒 This topic is solved and locked.