全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3713 5
2014-04-18
现有产生数据的代码如下,需要求出一个变量,如droptime,问最后一次p*的*如何求出。比如,subject id=1是,其最后一个非缺失值变量是P8,那么赋值8给droptime,即droptime=8;
subject id=11,最后一个非缺失值变量是P3, 就有droptime=3,对于最后一个非缺失值是P10的,定义droptime=10.请问如何实现?
我有个例子,但是不正确,请高手帮我改一下。

data Tumor;
   infile datalines missover;
   input ID Time Dead Dose P1-P15;
   label ID='Subject ID';
   datalines;
1 47 1  1.0  0  5  6  8 10 10 10 10
2 71 1  1.0  0  0  0  0  0  0  0  0  1  1  1  1 1 1 1
3 81 0  1.0  0  1  1  1  1  1  1  1  1  1  1  1 1 1 1
4 81 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0 0
5 81 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0 0
6 65 1  1.0  0  0  0  1  1  1  1  1  1  1  1  1 1
7 71 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0 0
8 69 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0
9 67 1  1.0  0  0  1  1  2  2  2  2  3  3  3  3 3 3
10 81 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0 0
11 37 1  1.0  9  9  9
12 81 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0 0
13 77 0  1.0  0  0  0  0  1  1  1  1  1  1  1  1 1 1 1
14 81 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0 0
15 81 0  1.0  0  0  0  0  0  0  0  0  0  0  0  0 0 0 0
16 54 0  2.5  0  1  1  1  2  2  2  2  2  2  2  2
17 53 0  2.5  0  0  0  0  0  0  0  0  0  0  0  0
18 38 0  2.5  5 13 14
19 54 0  2.5  2  6  6  6  6  6  6  6  6  6  6  6
20 51 1  2.5 15 15 15 16 16 17 17 17 17 17 17
21 47 1  2.5 13 20 20 20 20 20 20 20
22 27 1  2.5 22
23 41 1  2.5  6 13 13 13
24 49 1  2.5  0  3  3  3  3  3  3  3  3
25 53 0  2.5  0  0  1  1  1  1  1  1  1  1  1  1
26 50 1  2.5  0  0  2  3  4  6  6  6  6  6
27 37 1  2.5  3 15 15
28 49 1  2.5  2  3  3  3  3  4  4  4  4
29 46 1  2.5  4  6  7  9  9  9  9
30 48 0  2.5 15 26 26 26 26 26 26 26
31 54 0 10.0 12 14 15 15 15 15 15 15 15 15 15 15
32 37 1 10.0 12 16 17
33 53 1 10.0  3  6  6  6  6  6  6  6  6  6  6  6
34 45 1 10.0  4 12 15 20 20 20
35 53 0 10.0  6 10 13 13 13 15 15 15 15 15 15 20
36 49 1 10.0  0  2  2  2  2  2  2  2  2
37 39 0 10.0  7  8  8
38 27 1 10.0 17
39 49 1 10.0  0  6  9 14 14 14 14 14 14
40 43 1 10.0 14 18 20 20 20
41 28 0 10.0  8
42 34 1 10.0 11 18
43 45 1 10.0 10 12 16 16 16 16
44 37 1 10.0  0  1  1
45 43 1 10.0  9 19 19 19 19
;
run;


data tumor_;
        set tumor;
        drop p11-p15;
run;
/***Example*****/
data tumor1;
        set tumor_;
        ARRAY p[10];
        do droptime=1 to DIM(p);
                if MISSING (p[droptime]) then leave;
                       
                droptime=droptime+1;
               
        end;

run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-4-18 20:47:42
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-18 21:09:52
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-18 22:47:17
Wanted
如何产生上图?用一下代码好像产生不了。
/*Re-arrange the data so that we can plot the triangle plot */
data tumor1;
        set tumor_;
        ARRAY p[10];
        do droptime=1 to DIM(p);
                if MISSING (p[droptime]) then LEAVE;
        end;
        droptime=droptime-1;
        do MeasureTime=1 to dim(p);
                Npap=p[MeasureTime];
                output;
        end;
        keep ID MeasureTime Npap droptime;
run;

PROC MEANS data=tumor1 nway NOPRINT;
        CLASS droptime MeasureTime;
        VAR Npap;
        OUTPUT OUT=meanout mean=mean_Npap;
run;

/*how should change thses code to ensure with the dataset meanout, I can produce a sample graph?*/
proc template;
  define statgraph scatterplot;
    dynamic _X_ _Y_ _VMCG_ _MSIZE_ _LMCG_;

          begingraph;
            entrytitle "Figure 1:";
                layout overlay;
                  scatterplot x=_X_ y=_Y_ /name='sca' markercolorgradient=_VMCG_ markerattrs=(symbol=squarefilled size=_MSIZE_);
                  *discretelegend 'sca';
                  continuouslegend 'sca'/orient=vertical halign=right title=_LMCG_;
                endlayout;
        endgraph;
  end;
run;

ods graphics on/width=1000 height=1000;
proc sgrender data=meanout template=scatterplot;
    dynamic _X_='MeasureTime' _Y_='DropTime' _VCMG_='mean_Npap' _MSIZE_='30pt' _LMCG_='Npap';
        label MeasureTime="Measurment Time" DropTime="Dropout Time";
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-19 07:50:16
请帮帮我。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2014-4-19 16:47:23
suzhzh 发表于 2014-4-18 22:47
如何产生上图?用一下代码好像产生不了。
/*Re-arrange the data so that we can plot the triangle plo ...
正确的如下:
proc template;
  define statgraph scatterplot;
    dynamic _X_ _Y_  _MSIZE_ _LMCG_;

   begingraph;
     entrytitle "Figure 1:Trianlge Plot about (non)informative dropout";/*Plot the title*/
  layout overlay;
    scatterplot x=_X_ y=_Y_ /name='sca' markercolorgradient=mean_Npap markerattrs=(symbol=squarefilled size=_MSIZE_);
    *discretelegend 'sca';
    continuouslegend 'sca'/orient=vertical halign=right title=_LMCG_;
  endlayout;
endgraph;
  end;
run;

ods graphics on/width=1000 height=1000;
proc sgrender data=meanout(where=(mean_npap ne .))  template=scatterplot;
    dynamic _X_='MeasureTime' _Y_='DropTime'  _MSIZE_='30pt' _LMCG_='Npap';
label MeasureTime="Measurment Time" DropTime="Dropout Time" ;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群