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,

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 542 views
  • 0 likes
  • 3 in conversation