DATA Step, Macro, Functions and more

"ERROR: The AVG summary function requires a numeric argument." Why does it keep saying?

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

"ERROR: The AVG summary function requires a numeric argument." Why does it keep saying?

Hello!

 

I just have a minor error. I am sure this isn't a big deal, but I can't figure out the solution.

Here is my code:

proc sql;
create table test.class_analysis as
select sex, 
avg(age) as avg_age,
avg(height) as avg_height,
avg(weight) as avg_weight
from test.class
group by sex;
quit;

ERROR:  The AVG summary function requires a numeric argument.

So my question is, why does it keep saying error? It is in numeric values, I checked it. :/

 

Thank you all fro answers. Smiley Happy

 


Accepted Solutions
Solution
‎05-10-2017 05:00 AM
Super User
Posts: 7,758

Re: "ERROR: The AVG summary function requires a numeric argument." Why does it keep sayin

Since this works very well:

proc sql;
create table class_analysis as
select sex, 
avg(age) as avg_age,
avg(height) as avg_height,
avg(weight) as avg_weight
from sashelp.class
group by sex;
quit;

I suggest you do a proc contents on your dataset test.class and look at the output. At least one of the three analysis variables is of type character.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎05-10-2017 05:00 AM
Super User
Posts: 7,758

Re: "ERROR: The AVG summary function requires a numeric argument." Why does it keep sayin

Since this works very well:

proc sql;
create table class_analysis as
select sex, 
avg(age) as avg_age,
avg(height) as avg_height,
avg(weight) as avg_weight
from sashelp.class
group by sex;
quit;

I suggest you do a proc contents on your dataset test.class and look at the output. At least one of the three analysis variables is of type character.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 345

Re: "ERROR: The AVG summary function requires a numeric argument." Why does it keep sayin

Hardly possible to suggest anything useful without knowing the structure of test.class. The type of age, height and weight must be numeric. Maybe they are char and contain only numbers, but this violates the requirement of avg function.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 453 views
  • 0 likes
  • 3 in conversation