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
- /
- SAS Procedures
- /
- sum of column

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

08-26-2014 09:15 AM

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

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

Posted in reply to sasphd

08-26-2014 09:51 AM

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

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

Posted in reply to sasphd

08-26-2014 09:27 AM

proc print data=have;

sum a;

run;

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

Posted in reply to stat_sas

08-26-2014 09:31 AM

where is the output?

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

Posted in reply to sasphd

08-26-2014 09:33 AM

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

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

Posted in reply to stat_sas

08-26-2014 09:40 AM

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

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

Posted in reply to sasphd

08-26-2014 09:51 AM

proc sql;

create table want as

select sum(a=1)/count(a) as positive_alpha from have;

quit;

proc print data=want;

run;

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

Posted in reply to sasphd

08-26-2014 09:44 AM

simplest solution, IMO:

proc sql;

/* create table want as */

select sum(a) from have;

quit;

---------------------------------------------------------------------------------------------

Maxims of Maximally Efficient SAS Programmers

Maxims of Maximally Efficient SAS Programmers