turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- ERROR: Function SUM requires a numeric expression ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-21-2011 07:54 AM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-21-2011 08:26 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-21-2011 08:50 AM

> 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

> 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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-21-2011 08:56 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

04-21-2011 10:40 PM

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

[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