Help using Base SAS procedures

sum of column

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 118
Accepted Solution

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
Trusted Advisor
Posts: 1,204

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;

View solution in original post


All Replies
Trusted Advisor
Posts: 1,204

Re: sum of column

proc print data=have;

sum a;

run;

Frequent Contributor
Posts: 118

Re: sum of column

where is the output?

Trusted Advisor
Posts: 1,204

Re: sum of column

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

Frequent Contributor
Posts: 118

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
Trusted Advisor
Posts: 1,204

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: 6,972

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
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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