DATA Step, Macro, Functions and more

In search of a Base SAS function that does a SUM BY GROUP

Reply
Contributor
Posts: 44

In search of a Base SAS function that does a SUM BY GROUP

[ Edited ]

Hello,

 

I'm using SAS Model Implementation Platform and need to integrate some Base SAS code in order to do some calculations.

I would like to know if there's a function equivalent for this:

 

proc sql;
   select SUM(subaccount_EAD) as account_EAD
   from table
   group by account_number;
quit;

My variables are: account_number, subaccount_number and subaccount_EAD.

I'm looking for a function like: sumby.account_number(subaccount_EAD) if such a thing even exists.

I cannot use data steps or proc sql in MIP.

So, ... help?

SAS Super FREQ
Posts: 3,755

Re: In search of a Base SAS function: SUM BY GROUP

if you sort the data by the grouping variable, you can use BY group processing in the DATA step:

 

proc sort data=sashelp.class out=Class;
by sex;
run;

data Want;
set Class;
by Sex;
if first.Sex then sum=0;
sum + height;
if last.Sex then output;
keep Sex Sum;
run;

proc print;run;
Contributor
Posts: 44

Re: In search of a Base SAS function: SUM BY GROUP

[ Edited ]

Thank you for your post, but I cannot use any form of data steps, procedures or statements in MIP. ONLY functions.

Ask a Question
Discussion stats
  • 2 replies
  • 163 views
  • 0 likes
  • 2 in conversation