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 several variables by group

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

05-10-2017 11:24 AM

Hello All,

I have several columns: station year a b c d e f g ....

And I want to sum a,b,c,d,e,f,g,... by year.

DO I need to use macro or sql? And how to do it?

I would greatly appreciate it if any one can have any ideas!

Thanks a lot!

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

05-10-2017 11:25 AM

SQL

MEANS/SUMMARY

MEANS/SUMMARY

Data never sleeps

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

Posted in reply to LinusH

05-10-2017 01:07 PM

Do you know how to do sql?

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

05-10-2017 01:46 PM

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

Posted in reply to LinusH

05-10-2017 01:07 PM

Thank you!

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

05-10-2017 12:25 PM - edited 05-10-2017 12:26 PM

Use PROC SUMMARY.

```
proc summary data=have nway ;
by station year;
var a b c d e f g ....;
output out=want sum= ;
run;
```

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

05-10-2017 01:06 PM

Thanks you!

output out=want sum=a_sum b_sum c_sum ... ;

Is this correct? Will this give me the corresponding sum for all the variables?

output out=want sum=a_sum b_sum c_sum ... ;

Is this correct? Will this give me the corresponding sum for all the variables?