BookmarkSubscribeRSS Feed
adri05sv
Calcite | Level 5
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
4 REPLIES 4
art297
Opal | Level 21
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
darrylovia
Quartz | Level 8
> 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
adri05sv
Calcite | Level 5
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
Ksharp
Super User
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

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 13969 views
  • 0 likes
  • 4 in conversation