Help using Base SAS procedures

sum several variables by group

Reply
Contributor hua
Contributor
Posts: 66

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,424

Re: sum several variables by group

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

Re: sum several variables by group

Do you know how to do sql?
Super User
Posts: 19,771

Re: sum several variables by group

Contributor hua
Contributor
Posts: 66

Re: sum several variables by group

Thank you!
Super User
Super User
Posts: 7,039

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: 66

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
  • 185 views
  • 0 likes
  • 4 in conversation