BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Derdavos
Obsidian | Level 7

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. 🙂

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

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.

andreas_lds
Jade | Level 19

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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