-1
我需要使此代碼更高效(請參閱下文)。代碼正在做的是僅在「統一」中缺少觀察值的情況下,使用「均值」中的值更新「統一」主數據集。這會通過並更新16個變量。PROC SQL UPDATE - 效率
有沒有辦法讓這個更有效,如創建通過16個變量的循環?
proc sql;
update index.consolidated as a
set GRANTS_3YP = case when a.GRANTS_3YP ^= . then a.GRANTS_3YP else (select GRANTS_3YP from index.means as b where a.LGA = b.LGA) end,
GRANTS_3Y = case when a.GRANTS_3Y ^= . then a.GRANTS_3Y else (select GRANTS_3Y from index.means as b where a.LGA = b.LGA) end,
RI_GEN = case when a.RI_GEN ^= . then a.RI_GEN else (select RI_GEN from index.means as b where a.LGA = b.LGA) end,
FIFO = case when a.FIFO ^= . then a.FIFO else (select FIFO from index.means as b where a.LGA = b.LGA) end,
YU_3Y = case when a.YU_3Y ^= . then a.YU_3Y else (select YU_3Y from index.means as b where a.LGA = b.LGA) end,
POP_FLOWS = case when a.POP_FLOWS ^= . then a.POP_FLOWS else (select POP_FLOWS from index.means as b where a.LGA = b.LGA) end,
COL = case when a.COL ^= . then a.COL else (select COL from index.means as b where a.LGA = b.LGA) end,
IC = case when a.IC ^= . then a.IC else (select IC from index.means as b where a.LGA = b.LGA) end,
DISTANCE = case when a.DISTANCE ^= . then a.DISTANCE else (select DISTANCE from index.means as b where a.LGA = b.LGA) end,
MR_3Y = case when a.MR_3Y ^= . then a.MR_3Y else (select MR_3Y from index.means as b where a.LGA = b.LGA) end,
MP = case when a.MP ^= . then a.MP else (select MP from index.means as b where a.LGA = b.LGA) end,
DP = case when a.DP ^= . then a.DP else (select DP from index.means as b where a.LGA = b.LGA) end,
RENT = case when a.RENT ^= . then a.RENT else (select RENT from index.means as b where a.LGA = b.LGA) end,
DEATH = case when a.DEATH ^= . then a.DEATH else (select DEATH from index.means as b where a.LGA = b.LGA) end,
MENTAL = case when a.MENTAL ^= . then a.MENTAL else (select MENTAL from index.means as b where a.LGA = b.LGA) end,
AGE = case when a.AGE ^= . then a.AGE else (select AGE from index.means as b where a.LGA = b.LGA) end;
quit;