Help using Base SAS procedures

ERROR: Function SUM requires a numeric expression as argument 1

Reply
New Contributor
Posts: 4

ERROR: Function SUM requires a numeric expression as argument 1

Hi

I am trying to sum using proc sql but I get the following on the log window

proc sql;
519 create table limbs3 as
520 select
521 id,
522 sum(sum(normal, alo2, call3, red4, wound5, callswe6,
523 swound7, sswe8, swound_sswe9)) as score
524 FROM limbs_sum;
ERROR: Function SUM requires a numeric expression as argument 1.
ERROR: Function SUM requires a numeric expression as argument 2.
ERROR: Function SUM requires a numeric expression as argument 3.
ERROR: Function SUM requires a numeric expression as argument 4.
ERROR: Function SUM requires a numeric expression as argument 5.
ERROR: Function SUM requires a numeric expression as argument 6.
ERROR: Function SUM requires a numeric expression as argument 7.
ERROR: Function SUM requires a numeric expression as argument 8.
ERROR: Function SUM requires a numeric expression as argument 9.
ERROR: The SUM summary function requires a numeric argument.
525 group by id;
526 quit;


what am I doing wrong?

Thanks for your help
PROC Star
Posts: 7,471

Re: ERROR: Function SUM requires a numeric expression as argument 1

Why does your sum statement have two 'sum' functions? I can't test it at the moment, but would suggest trying it as sum(normal,etc., etc.).

Art
-----------
> Hi
>
> I am trying to sum using proc sql but I get the
> following on the log window
>
> proc sql;
> 519 create table limbs3 as
> 520 select
> 521 id,
> 522 sum(sum(normal, alo2, call3, red4, wound5,
> callswe6,
> 523 swound7, sswe8, swound_sswe9)) as score
> 524 FROM limbs_sum;
> ERROR: Function SUM requires a numeric expression as
> argument 1.
> ERROR: Function SUM requires a numeric expression as
> argument 2.
> ERROR: Function SUM requires a numeric expression as
> argument 3.
> ERROR: Function SUM requires a numeric expression as
> argument 4.
> ERROR: Function SUM requires a numeric expression as
> argument 5.
> ERROR: Function SUM requires a numeric expression as
> argument 6.
> ERROR: Function SUM requires a numeric expression as
> argument 7.
> ERROR: Function SUM requires a numeric expression as
> argument 8.
> ERROR: Function SUM requires a numeric expression as
> argument 9.
> ERROR: The SUM summary function requires a numeric
> argument.
> 525 group by id;
> 526 quit;
>
>
> what am I doing wrong?
>
> Thanks for your help
Frequent Contributor
Posts: 139

Re: ERROR: Function SUM requires a numeric expression as argument 1

> Why does your sum statement have two 'sum' functions?
> I can't test it at the moment, but would suggest
> trying it as sum(normal,etc., etc.).
>
> Art
> -----------
> > Hi
> >
> > I am trying to sum using proc sql but I get the
> > following on the log window
> >
> > proc sql;
> > 519 create table limbs3 as
> > 520 select
> > 521 id,
> > 522 sum(sum(normal, alo2, call3, red4, wound5,
> > callswe6,
> > 523 swound7, sswe8, swound_sswe9)) as
> score
> > 524 FROM limbs_sum;
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 1.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 2.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 3.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 4.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 5.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 6.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 7.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 8.
> > ERROR: Function SUM requires a numeric expression
> as
> > argument 9.
> > ERROR: The SUM summary function requires a numeric
> > argument.
> > 525 group by id;
> > 526 quit;
> >
> >
> > what am I doing wrong?
> >
> > Thanks for your help


I think you put a semi-colon after your FROM CLAUSE and that needs to be removed.
The syntax works for me by using the below code
proc sql;
create table table1 as
select region
,sum(sum(sales,returns)) as gross_sales
from sashelp.shoes
group by region;
quit;

yet if I use a char data type i get your message. see below

16 proc sql;
17 create table table3 as
18 select region
19 ,sum(sum(product,returns)) as gross_sales
20 from sashelp.shoes
21 group by region;
ERROR: Function SUM requires a numeric expression as argument 1.
ERROR: The SUM summary function requires a numeric argument.

Also I would check the data types of your table

proc sql;
describe table limbs_sum;
quit;

to double check

Add to Art297. the sum by itself just adds the columns together, the double sum then aggregates the summed columns .

D
New Contributor
Posts: 4

Re: ERROR: Function SUM requires a numeric expression as argument 1

Hi,
I found that if a sum function is nested into another sum function SAS will produce a grand total of the calculated variables across the observations. For each individual I have 18 observations and I need a total score for each one. I tried with only one sum function but I get the same error message
Super User
Posts: 10,023

Re: ERROR: Function SUM requires a numeric expression as argument 1

How about this:
[pre]
proc sql;
create table total as
select name,sum(weight,height) as sub_sum,sum(calculated sub_sum) as grand_sum
from sashelp.class
;
quit;
[/pre]


Ksharp
Ask a Question
Discussion stats
  • 4 replies
  • 5275 views
  • 0 likes
  • 4 in conversation