BookmarkSubscribeRSS Feed
adrfinance
Obsidian | Level 7

I am using the following code to estimate the average of a column:

 

rsubmit;
proc sql;
create table want as
select *, mean(total_balance) as avg_balance
from have;
quit;
endrsubmit;

 

in the following dataset:

 

total balance

100

200

300

400

 

and I am getting output

 

total balance avg_balance

100               100

200               200

300               300

400               400

 

instead of 

 

total balance avg_balance

100               250

200               250

300               250

400               250

 

 

what am I doing wrong?

4 REPLIES 4
AndreaVianello
Obsidian | Level 7

my solution:

 

data have;
input total_balance;
cards;
100
200
300
400
;run;

 


proc sql;
create table want as
select * , mean(total_balance) as avg_balance
from have
;quit;

 

 

ed_sas_member
Meteorite | Level 14

Hi @adrfinance 

 

That's very tricky because when I run the proc sql step, I get the right result.

I don't use the rsubmit / rendsubmit statements.

Do you have any message in the log ?

adrfinance
Obsidian | Level 7

Yes I am also getting the correct result, my bad -- sorry!, is there a way to delete this question?

ed_sas_member
Meteorite | Level 14

No problem 🙂

I think you can delete the post by using the icon on upper right

Or mark it as answered to close it.

Best,