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,

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 480 views
  • 0 likes
  • 3 in conversation