Help using Base SAS procedures

sum several variables by group

Reply
Contributor hua
Contributor
Posts: 36

sum several variables by group

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!

Super User
Posts: 5,256

Re: sum several variables by group

SQL
MEANS/SUMMARY
Data never sleeps
Contributor hua
Contributor
Posts: 36

Re: sum several variables by group

Do you know how to do sql?
Super User
Posts: 17,784

Re: sum several variables by group

Contributor hua
Contributor
Posts: 36

Re: sum several variables by group

Thank you!
Super User
Super User
Posts: 6,499

Re: sum several variables by group

[ Edited ]

Use PROC SUMMARY.

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

Re: sum several variables by group

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?
Ask a Question
Discussion stats
  • 6 replies
  • 134 views
  • 0 likes
  • 4 in conversation