楼主: jingju11
13684 52

[学习分享] 讲一讲 SAS 9.3 [推广有奖]

41
jingju11 发表于 2011-12-1 07:28:12
Continue…

  1. data outSurv2;
  2.    array _perc[9] _temporary_ (5 10 15 20 25 30 40 50 75);
  3.    array _atRisk[8] _temporary_ (0 12 24 36 48 60 72 84);
  4.    set outSurv11 end =Eof;
  5.    Failure=1 -survival;
  6.    do p =1 to nobs;
  7.       set outSurv1 (keep =Time_m survival rename =(Time_m =_00Time_m survival =_00Survival)) point =p nobs =nobs;      
  8.       if SDF_UCL >_00Survival then time_LCL =min(time_LCL, _00Time_m);
  9.       if SDF_LCL >_00Survival then time_UCL =min(time_UCL, _00Time_m);
  10.     end;
  11.    retain time_CL;
  12.    if cmiss(time_LCL, time_UCL) ^=2 then time_CL =cats(put(time_m, 5.0))||' ('||catx(' - ', put(time_LCL, 5.0), put(time_UCL, 5.0))||')';
  13.    lag1Failure =lag1(Failure); lag1time_CL =lag1(time_CL);
  14.    do i =1 to 9;
  15.          if Failure>_perc/100 and lag1Failure <=_perc/100 then do;
  16.             perc =_perc; percY =perc /100;
  17.             time_CLchar =lag1time_CL;
  18.             i =9+1;
  19.          end;
  20.       end;
  21.    lag1Time_m =lag1(Time_m);
  22.    retain NumberAtRisk0;
  23.    if not missing(NumberAtRisk) then NumberAtRisk0 =NumberAtRisk;
  24.     do i =1 to 8;
  25.          if Time_m >=_atRisk/1.00 and lag1Time_m <_atRisk/1.00 then do;
  26.             atriskX =_atRisk;
  27.             atriskChar =cats(NumberAtRisk0);
  28.             i =9+1;
  29.          end;
  30.    end;
  31.    percX =3;
  32.    atriskY =-0.05;
  33.    if _censor_ then censorChar ='+'; *mark the censored;
  34.    if Eof then do;
  35.       atriskX =84;
  36.       atriskChar ='#at risk';
  37.    end;
  38.    keep time_m Failure censorChar atriskX atriskY atriskChar percX percY time_CLChar;
  39. run;

  40. proc sgplot data = outSurv2 noautolegend;
  41.    step x =time_m y =Failure;
  42.    scatter x =time_m y =Failure/markerchar =censorChar;
  43.    scatter x =atriskX y =atriskY/markerchar =atriskChar markercharattrs =(family ='Times' size =09pt style =normal weight =bold);
  44.    scatter x =percX y =percY/markerchar =time_CLchar markercharattrs =(family ='Times' size =09pt style =normal weight =bold);
  45.    inset " " " "
  46.             "Failure months (95% CL)"/ noborder position =topleft textattrs =(family ='Times' size =10pt style =normal weight =bold);
  47.    xaxis grid label ='Follow-up in Months' values =(0 to 84 by 12) offsetmin =0.060 offsetmax =0.045;
  48.    yaxis label ='Estimated probability of infection' grid values =(0 0.05 0.10 0.15 0.20 0.25 0.30 0.40 0.50 0.75 1.00) offsetmin =0.075;
  49.    format Failure percentn6.0;
  50. run;
复制代码




42
jingju11 发表于 2011-12-1 08:05:05
To get means from quantile-range data as that question. Of note, this code is not verified.
JingJu

proc sort data =had out =have; by sharp;
run;
data have2;
   keep Q1m Q3m;
   do p =1 to n;
      set have point =p nobs =n;
      if p <=ceil(1/4 *n) then Q1m ++(sharp -Q1m)/p;
         else if p >ceil(3/4 *n) then Q3m ++(sharp -Q3m)/(p -ceil(3/4 *n));
   end;
   output;
   stop;
run;





43
ademons 发表于 2011-12-1 15:06:00
SAS 9.3的ods rtf有问题,让我很郁闷。

44
jingju11 发表于 2011-12-1 22:43:54
ademons 发表于 2011-12-1 15:06
SAS 9.3的ods rtf有问题,让我很郁闷。
我看了你的帖子。我觉得你没有清晰描述你的问题。京剧

45
ademons 发表于 2011-12-2 18:03:56
    ademons 发表于 2011-12-1 15:06
    SAS 9.3的ods rtf有问题,让我很郁闷。

我看了你的帖子。我觉得你没有清晰描述你的问题。京剧
------------------------------------------------------
就是orientation=landscape的页面后面的 orientation=portrait 的页面非常窄。我设定了options papersize=A4,没有用。另外,ods rtf text=“string”与换页与横竖版转换这三者之间的关系我还没有搞懂。(现在手边没有程序)总之,我原来的程序在9.3上产生了一个标题位置换页及页面都很古怪的rtf文件。

46
jingju11 发表于 2011-12-2 23:57:06
A revisited meta plot. JingJu


forest plot2.png
data anno;
  set meta end=Eof;
   length label $ 50 anchor $ 6 y1space $ 13 x1space $ 12 textcolor textStyle $12;
   retain function "text" y1space "datavalue" width 50 anchor "left" textsize 8 textweight "normal" ;
   textcolor ="black";
   textStyle ="normal";
   if study ='Overall' then do;
      textsize =8; textcolor ='orange'; textweight ="bold" ; textStyle ="italic";
   end;
   yc1=study;
   label=study;
   x1space="graphpercent";
   x1=1;
   output;
   label=summary;
   x1space="wallpercent";
   x1=101;
   output;
   if (Eof) then do;
      yc1=" ";
      x1space="wallpercent";
      y1space="graphpercent";
      anchor="bottom";
      y1=2;
      x1=25;
      label="Favors Treatment"; textweight ="bold"; textcolor ="green"; textStyle ="normal";
      output;
      x1=75;
      label="Favors Placebo"; textweight ="bold"; textcolor ="purple";
      output;
      y1space="wallpercent";
      x1space="wallpercent";
      y1=100;
      x1=-12;
      label="Study"; textweight ="bold"; textcolor ="black";
      output;
      x1=105;
      label="OR"; textweight ="bold"; textcolor ="black";
      output;
      x1=116;
      label="(LCL, UCL)";textweight ="bold";
      output;
   end;
run;




47
jingju11 发表于 2011-12-3 00:01:35
con't..
data attrmap;
  length  markercolor  linecolor  linepattern $12 fillcolor $20; drop year_type;
   retain ID "StudyName" markersymbol "squarefilled";
   set meta(keep =study year_type) end =Eof;
   retain markercolor  linecolor  linepattern ;
   value =study;
   if year_type =0 then do;
      markercolor ='red'; linecolor ='red';  linepattern ='solid'; fillcolor ='very_light_red';
   end;
   if year_type=1 then do;
      markercolor ='blue'; linecolor ='blue';  linepattern ='solid'; fillcolor ='very_light_blue';
   end;
   if study ='Overall' then do;
      markercolor ='orange'; linecolor ='orange';  markersymbol ="diamond"; linepattern ='shortdash';
   end;
run;
title 'Impact of Treatment on Mortality';
title2 height =7pt 'Odds Ratio and 95% CL';
ods rtf image_dpi =300;
proc sgplot data=meta nocycleattrs noautolegend sganno=anno dattrmap=attrmap pad=(left=18% right=22.5% bottom=5% top =1.5%);
yaxis reverse display=none;
xaxis type=log logbase=10 min=.01 max=100 minor display=(nolabel) offsetmin=0 offsetmax=0;
refline 1 / axis=x;
refline .01 .1 10 100 / axis=x lineattrs=GraphGridLines;
highlow y=study high=UpperCL low=LowerCL/ attrid=StudyName group =study;
scatter y=study x=oddsratio/ attrid=StudyName group =study;
bubble y =study x =oddsratio size =weight /datalabel =weight nooutline bradiusmin =0.045cm bradiusmax =0.090cm attrid=StudyName group =study;
run;
ods rtf close;


48
jingju11 发表于 2012-1-15 01:36:41
预祝大家春节愉快,万事如意。sas水平大大提高。京剧

49
oloolo 发表于 2012-1-15 06:02:28
9.3里面的 HPMIXED 支持的协方差阵类型更多,这个对我很重要。

50
oloolo 发表于 2012-1-15 06:02:40
9.3里面的 HPMIXED 支持的协方差阵类型更多,这个对我很重要。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-2 05:41