You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* The procedure to fill NA values using average risk in risk tables */
-- @var_name = variable name
-- @risk_table_name = the risk table to be used
-- @table the table you want to update: training or testing
use [OnlineFraudDetection]
go
setansi_nullson
go
setquoted_identifieron
go
DROPPROCEDUREIFEXISTSdbo.FillNA
GO
createproceduredbo.FillNA
@var_name varchar(max),
@risk_table_name varchar(max),
@table varchar(max)
as
begin
declare @sql nvarchar(max)
set @sql ='update '+replace(@table, '''','''''') +
'
set '+replace(@var_name, '''','''''') +'_risk = case when '+replace(@var_name, '''','''''') +'_risk is null then x.mean else '+replace(@var_name, '''','''''') +'_risk end
from (select avg(risk) as mean from '+replace(@risk_table_name, '''','''''') +') x;'