全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
10266 2
2016-01-18
悬赏 200 个论坛币 未解决
各位大神,我想利用多因素Logistic回归后得到的各因素的OR值、OR值的95%CI和P值做森林图,如这张网上找到的图。我想要的结果与其类似,但是想要每个因素的第一个水平作参照,起OR值为1或无,参照水平无置信区间。感谢帮忙的人。
%$X2T7$NH2THQ~7ZJO2FLH1.jpg

原图尺寸 89.13 KB

%$X2T7$NH2THQ~7ZJO2FLH1.jpg

二维码

扫码加我 拉你入群

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

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

全部回复
2016-6-30 23:03:27
这个简单,我做一个类似的吧
data or;
input param $10.  or min max  p;
cards;
sex                0.81        1.23        0.53                0.33
age             0.70        1.53        0.52                0.06
bmi                0.85        1.39        0.64                0.29
eduacation         0.89        1.10        0.70                0.76
;
run;


data tot;
        set or;
           CI=put(min,7.2)||' to '||put(max,7.2. -l);
        ord=_n_;
        retain constant 1;
run;


ods path work.templ(update) sashelp.tmplmst(read) sashelp.styles(read);

proc template;
define style mystyle;
parent = Styles.default;
style parskip / fontsize = 0pt;
class text / 'continued' = " ";
class Continued /
         frame=void
         pretext = _undef_
         borderspacing = 0      
         padding = 0 ;     
class GraphBackground/
   backgroundcolor =  white
   color = white;
  class LayoutContainer /
      padding = 0
      borderspacing = 0
      borderwidth = 0
      frame = void
      rules = none
      backgroundcolor = _undef_;
style GraphFonts from GraphFonts/
   'GraphDataFont'=('Times New Roman' ,12pt)
   'GraphUnicodeFont'=('Times New Roman' ,12pt)
   'GraphValueFont'=('Times New Roman' ,12pt)
   'GraphLabelFont'=('Times New Roman' ,12pt)
   'GraphFootnoteFont'=('Times New Roman' ,12pt)  /*Times New Roman*/
   'GraphTitleFont'=('Times New Roman' ,12pt)
   'GraphAnnoFont'=('Times New Roman' ,12pt);

class graph/
   fontweight=bold;
end;
run;





proc template;
  define statgraph ForestPlot;
  begingraph / designwidth=9in designheight=16in;
  layout lattice / columns=3 columngutter=0 columnweights=(0.10 .60 .30 );


layout overlay / walldisplay=none border=false
                   yaxisopts=(reverse=true type=discrete display=none)
                   xaxisopts=(display=none offsetmin=0.25 offsetmax=0.25);
           entry halign=left   "        Parameter" / location=outside valign=top ;
          
      scatterplot y=ord x=eval(constant*1) / markercharacter=param;
        endlayout;  



layout overlay /walldisplay=(fill)
yaxisopts=(display=none reverse=true offsetmin=0.00 offsetmax=0.10)
                   xaxisopts=(type=log offsetmin=0.00 offsetmax=0.00
                           label="<-----Protect Factor   Harm Factor----->"
                  logopts=(base=10 minorticks=true viewmin=0.01 viewmax=100 ) );
      entry halign=center "OR and 95% CIs" / location=outside valign=top ;
      scatterplot y=ord  x=or / xerrorupper=max xerrorlower=min  
           markerattrs=graphdata1(symbol=diamondfilled size=1pct);  
            referenceline x=1 / lineattrs=(pattern=solid);
      referenceline x=0.1 / lineattrs=(pattern=shortdash);
      referenceline x=10 / lineattrs=(pattern=shortdash);
    endlayout;

         layout overlay / walldisplay=none border=false
                   yaxisopts=(reverse=true type=discrete display=none)
                   xaxisopts=(display=none offsetmin=0.25 offsetmax=0.25);
           entry halign=left            "                   OR             95% CI            P" / location=outside valign=top ;
          
      scatterplot y=ord x=eval(constant*1) / markercharacter=or;
          scatterplot y=ord x=eval(constant*2) / markercharacter=ci;
          scatterplot y=ord x=eval(constant*3) / markercharacter=p;
    endlayout;  


  endlayout;
  endgraph;
  end;
run;


/*ods graphics on / height=5.5 in width=10 in border=off;*/
ods rtf file="d:\test.rtf"  style=mystyle;
proc sgrender data=tot template=ForestPlot;
run;
ods rtf close;

二维码

扫码加我 拉你入群

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

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

2017-12-16 20:17:15
请教大神,用sgplot的程序是什么样的,谢谢!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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