Hello All,
I am modifying an existing code and facing Error - "the mean summary function requires a numeric argument"
The Code is:-
proc sql;
create table ECL_&report_mth._Sum as
select report_mth
,final_stage
,count(ECL) as volume
,sum (balance) as balance
,sum (ECL) as ECL
,mean(ECL) as avg_ECL
,sum (ECL_Post) as ECL_Post
,mean(ECL_Post) as avg_ECL_Post
,mean(PiT_PD) as PiT_PD
from ECL_&report_mth._Study2
group by 1,2;
quit;
I see Null Values in ECL_&report_mth._Study2 table so I guess this is related to it.
Can anyone please tell me what should be added in order to resolve this error???
The Mean Funtion can handle missing/null values. The problem is that one of the variables being fed to the Mean Function is not numeric.
By "null" value do you mean that you see TEXT of NULL in the data set? That very likely means that variable is not numeric as unless you do some work with custom formats SAS will not display missing (i.e. "null") values as the word Null.
@NikitaA wrote:
Hello All,
I am modifying an existing code and facing Error - "the mean summary function requires a numeric argument"
The Code is:-
proc sql;
create table ECL_&report_mth._Sum as
select report_mth
,final_stage,count(ECL) as volume
,sum (balance) as balance
,sum (ECL) as ECL
,mean(ECL) as avg_ECL
,sum (ECL_Post) as ECL_Post
,mean(ECL_Post) as avg_ECL_Post
,mean(PiT_PD) as PiT_PD
from ECL_&report_mth._Study2
group by 1,2;
quit;I see Null Values in ECL_&report_mth._Study2 table so I guess this is related to it.
Can anyone please tell me what should be added in order to resolve this error???
Yes, You're right! Can you please suggest how to fix this?
Thanks
You must find out why a variable supposed to be numeric is in fact character. You have to inspect the process which creates your dataset.
Ah I understand, thanks... We have recently experienced change in our process and started importing an excel file which has Null values and hence causing this problem.
Thanks Again!
Hello All, I am modifying an existing code and facing Error - "the mean summary function requires a numeric argument" The Code is:- proc sql; create table ECL_&report_mth._Sum as select report_mth ,final_stage ,count(ECL) as volume ,sum (balance) as balance ,sum (ECL) as ECL ,mean(ECL) as avg_ECL ,sum (ECL_Post) as ECL_Post ,mean(ECL_Post) as avg_ECL_Post ,mean(PiT_PD) as PiT_PD from ECL_&report_mth._Study2 group by 1,2; quit; I see Null Values in ECL_&report_mth._Study2 table so I guess this is related to it.
Can anyone please tell me How can I fix this error???
I moved this back in here, as the question is still the same.
Excel files are notoriously bad as means for transporting data across environments. Use text files which you read with a data step, where you have total control over column attributes.
In addition to the good replies so far, do you understand that replace a null with a zero and then computing a mean produces and invalid and incorrect mean value? I strongly advise against this.
proc sql; create table ECL_&report_mth._Sum as select report_mth ,final_stage ,count(ECL) as volume ,sum (balance) as balance ,sum (ECL) as ECL ,mean(ECL) as avg_ECL ,sum (ECL_Post) as ECL_Post ,mean(ECL_Post) as avg_ECL_Post ,mean(PiT_PD) as PiT_PD from ECL_&report_mth._Study2 group by 1,2; quit;
One of the variables in the MEAN statement (highlighted) is character and needs to be numeric. If so, you should also get errors on the SUM statements. PiT_PD is the only variable that's only on the MEAN statement so it could be that variable but it's easy enough to check them all.
Yes, that's true... Can you please suggest how to fix this??
Thanks!
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.