【问题标题】:Running multiple arrays in SAS在 SAS 中运行多个阵列
【发布时间】:2020-03-19 01:33:57
【问题描述】:

我试图在我的 SAS 代码中运行 3 个数组并将每个值输入到最后一个数组中的变量中,但是,每次我运行此代码时,它只会填充 CREVASC_age 列。请告诉我有关如何使用其他数组中的匹配变量填充第三个数组中的每个年龄变量的任何想法。

    data Outc_adjust3; set Outc_adjust2;

    ARRAY outcvars{3} CABG MI CREVASC;

    ARRAY outcdys{3} CABGDY MIDY CREVASCDY;

    ARRAY outc_age{3} CABG_age MI_age CREVASC_age;

    Do I= 1 to 3;

        if outcvars{3} = 1 then outc_age{3} = ageatenroll + (outcdys(3)/365.25);

        else if outcvars{3} = 0 then do; 

           if EXTFLAG = 0 AND EXT2FLAG = 0 then outc_age{3} = AGE_WHIENDFU;

           if EXTFLAG = 1 AND EXT2FLAG = 0 then outc_age{3} = AGE_EXT1ENDFU;

           if EXT2FLAG = 1 AND EXT2MRC = 1 then outc_age{3} = age_endfu;

           if EXT2FLAG = 1 AND EXT2SRC = 1 then outc_age{3} = age_ext1endfu;

        end;
    end;

    run;

【问题讨论】:

    标签: sas


    【解决方案1】:

    您在需要 {I} 时硬编码了 {3}。这就是为什么只处理数组的第三个变量的原因。

    将循环内所有数组索引引用的{3} 更改为{I}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-11
      • 1970-01-01
      相关资源
      最近更新 更多