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?
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;
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 ?
Yes I am also getting the correct result, my bad -- sorry!, is there a way to delete this question?
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,
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.