Lapis Lazuli | Level 10

sum of column

I want to sum the observations of a column.

A

1

2

6

3

=

Total 12

1 ACCEPTED SOLUTION

Accepted Solutions
Ammonite | Level 13

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;

6 REPLIES 6
Ammonite | Level 13

Re: sum of column

proc print data=have;

sum a;

run;

Lapis Lazuli | Level 10

Re: sum of column

where is the output?

Ammonite | Level 13

Re: sum of column

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

Lapis Lazuli | Level 10

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

Ammonite | Level 13

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

Re: sum of column

simplest solution, IMO:

proc sql;

/* create table want as */

select sum(a) from have;

quit;

Discussion stats
• 6 replies
• 1484 views
• 0 likes
• 3 in conversation