當您在分析健保資料時,一次要定義幾個診斷碼,甚至許多的疾病,有什麼SAS程式指令是有效率又好維護的呢?
這是 #以斯帖統計 的Youtube頻道新單元,這個單元是健保資料分析課程的Sophie老師為我們錄製影片!影片中介紹 #array指令 的操作,當您知道如何使用這指令,將更有效率地執行相似的重覆動作,例如將門診3組診斷碼定義為特定的疾病。
快進來看吧!希望能對您的資料分析有幫助。
/*--原始程式--*/
data aa;
input (icd9_1 icd9_2 icd9_3)($);
if substr(icd9_1,1,3)='250' | substr(icd9_2,1,3)='250' | substr(icd9_3,1,3)='250' then dm=1;
if substr(icd9_1,1,3)='493' | substr(icd9_2,1,3)='493' | substr(icd9_3,1,3)='493' then as=1;
cards;
250.00 404.03 493.02
250.12 255.0 296.0
493.11 405.09 410.22
;
proc print;
run;
/*--Array 程式-*/
data aa;
input (icd9_1 icd9_2 icd9_3)($);
array icdx{3} $ icd9_1- icd9_3;
do i=1 to 3;
if substr(icdx{i},1,3)='250' then dm=1;
if substr(icdx{i},1,3)='493' then as=1;
end;
cards;
250.00 404.03 493.02
250.12 255.0 296.0
493.11 405.09 410.22
;
proc print;
run;