楼主: seanfang1992
1834 4

求SAS %Lexis宏文件 [推广有奖]

  • 0关注
  • 0粉丝

高中生

95%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
185 点
帖子
18
精华
0
在线时间
56 小时
注册时间
2015-7-8
最后登录
2018-7-12

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
首先祝大家中秋节快乐!
最近老板给了一个SAS程序里面涉及到了一个宏%Lexis,我查了相关文献,据说在http://wwww.biostat.ku.dk/~bxc/Lexis/Lexis.sas上可以获得,but我怎么都进不去,google翻墙失败,
求助各位大神,在哪里可以下载到这个宏,或者哪位大神电脑里有是否可以分享一下!、
小女子谢过各位!
二维码

扫码加我 拉你入群

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

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

关键词:EXI Lex Biostat Google 中秋节快乐 SAS

沙发
Arsaces 发表于 2016-9-15 23:43:43 |只看作者 |坛友微信交流群
是这个吗?
  1. /**************************************************************************
  2. Author: Bendix Carstensen, 1999-2002
  3. Update: Paul Dickman, BxC, November 2003
  4. Bug-fix: BxC, December 2007:
  5.          If the origin= argument had missing values erroneous output would
  6.          be generated (too much risk time). Now remedied so that
  7.          observations with missing values of origin are excluded.
  8. This macro is in: http://BendixCarstensen.com/Lexis/Lexis.sas
  9. Example program:  http://BendixCarstensen.com/Lexis/xLexis.sas
  10. ***************************************************************************/

  11. %macro Lexis ( data = ,       /* Data set with original data,             */
  12.                               /*    defaults to _last_                    */
  13.                 out = ,       /* Where to put the result,                 */
  14.                               /*    defaults to &data.                    */
  15.               entry = entry,  /* Variable holding the entry date          */
  16.                exit = exit,   /* Variable holding the exit date           */
  17.                fail = fail,   /* Variable holding the exit status         */
  18.                               /* If any of the entry, exit or fail        */
  19.                               /*    variables are missing the person is   */
  20.                               /*    discarded from the computations.      */
  21.              breaks = ,       /* Specification of the cutpoints on        */
  22.                               /*    the transformed scale.                */
  23.                               /*    Syntax as for a do statement.         */
  24.                               /*    The ONLY Mandatory argument.          */
  25.                cens = 0,      /* Code for censoring (may be a variable)   */
  26.               scale = 1,      /* Factor to transform from the scale       */
  27.                               /*    of entry and exit to the scale        */
  28.                               /*    where breaks and risk are given       */
  29.              origin = 0,      /* Origin of the transformed scale          */
  30.                risk = risk,   /* Variable recieving the risk time         */
  31.               lrisk = lrisk,  /* Variable recieving the log(risk time)    */
  32.                left = left,   /* Variable recieving left  endpoint of int */
  33.               other = ,       /* Other dataset statements to be used such */
  34.                               /*     as: %str( format var ddmmyy10. ; )   */
  35.                               /*     or: %str( label risk ="P-years" ; )  */
  36.                disc = discrd, /* Dataset holding discarded observations   */
  37.            /*-------------------------------------------------------------*/
  38.            /* Variables for making life-tables and other housekeeping:    */
  39.            /* These will only appear in the output dataset if given here  */
  40.            /* The existence of these arguments are tested in the macro so */
  41.            /* they cannot have names that are also logical operators such */
  42.            /* as: or, and, eq, ne, le, lt, gt.                            */
  43.            /*-------------------------------------------------------------*/
  44.               right = ,       /* Variable recieving right endpoint of int */
  45.                lint = ,       /* Variable recieving interval length       */
  46.             os_left = ,       /* Variable recieving left  endpoint of int */
  47.            os_right = ,       /* Variable recieving right endpoint of int */
  48.             os_lint = ,       /* Variable recieving interval length       */
  49.                               /*    - the latter three on original scale  */
  50.                cint = ,       /* Variable recieving censoring indicator   */
  51.                               /*    for the current input record          */
  52.                nint =         /* Variable recieving index of follow-up    */
  53.                               /*       interval;                          */
  54.               );

  55. %if &breaks.= %then %put ERROR: breaks MUST be specified. ;
  56. %if &data.  = %then %let data = &syslast. ;
  57. %if &out.   = %then %do ;
  58.                     %let out=&data. ;
  59.                     %put
  60. NOTE: Output dataset not specified, input dataset %upcase(&data.) will be overwritten. ;
  61.                   %end ;

  62. data &disc. &out. ;
  63.   set &data. ;
  64.   if ( nmiss ( &entry., &exit., &fail., &origin. ) gt 0 )
  65.      then do ; output &disc. ;
  66.                goto next ;
  67.           end ;
  68.   * Labelling of variables ;
  69.   label &entry.  = 'Entry into interval' ;
  70.   label &exit.   = 'Exit from interval' ;
  71.   label &fail.   = 'Failure indicator for interval' ;
  72.   label &risk.   = 'Risktime in interval' ;
  73.   label &lrisk.  = 'Natural log of risktime in interval' ;
  74.   label &left.   = 'Left endpoint of interval (transformed scale)' ;
  75. %if    &right.^= %then  label &right. = 'Right endpoint of interval (transformed scale)' ; ;
  76. %if     &lint.^= %then  label &lint. = 'Interval width (transformed scale)' ; ;
  77. %if  &os_left.^= %then  label &os_left. = 'Left endpoint of interval (original scale)' ; ;
  78. %if &os_right.^= %then  label &os_right. = 'Right endpoint of interval (original scale)' ; ;
  79. %if  &os_lint.^= %then  label &os_lint. = 'Interval width (original scale)' ; ;
  80. %if     &cint.^= %then  label &cint. = 'Indicator for censoring during the interval' ; ;
  81. %if     &nint.^= %then  label &nint. = 'Sequential index for follow-up interval' ; ;
  82.   &other. ;
  83.   drop _entry_ _exit_ _fail_
  84.        _origin_ _break_
  85.        _cur_r _cur_l _int_r _int_l
  86.        _first_ _cint_ _nint_;

  87. /*
  88. Temporary variables in this macro:

  89.   _entry_  holds entry date on the transformed timescale
  90.   _exit_   holds exit  date on the transformed timescale
  91.   _fail_   holds exit  status
  92.   _break_  current cut-point
  93.   _origin_ origin of the time scale
  94.   _cur_l   left  endpoint of current risk interval
  95.   _cur_r   right endpoint of current risk interval
  96.   _int_l   left  endpoint of current break interval
  97.   _int_r   right endpoint of current break interval
  98.   _first_  indicator for processing of the first break interval
  99.   _cint_   indicator for censoring during the interval
  100.   _nint_   sequential index of interval

  101. If a variable with any of these names appear in the input dataset it will
  102. not be present in the output dataset.
  103. */

  104.   _origin_ = &origin. ;
  105.   _entry_  = ( &entry. - _origin_ ) / &scale. ;
  106.   _exit_   = ( &exit.  - _origin_ ) / &scale. ;
  107.   _fail_   = &fail. ;
  108.   _cur_l   = _entry_ ;
  109.   _first_  = 1 ;

  110.   do _break_ = &breaks. ;
  111.      if _first_ then do ;
  112.         _nint_=-1;
  113.         _cur_l = max ( _break_, _entry_ ) ;
  114.         _int_l = _break_ ;
  115.      end ;
  116.      _nint_ + 1;
  117.      _first_ = 0 ;
  118.      _int_r = _break_ ;
  119.      _cur_r = min ( _exit_, _break_ ) ;
  120.      if _cur_r gt _cur_l then do ;
  121. /*
  122. Endpoints of risk interval are put back on original scale.
  123. If any of left or right are specified the corresponding endpoint
  124. of the break-interval are output.
  125. */
  126.         &entry.  = _cur_l * &scale. + _origin_ ;
  127.         &exit.   = _cur_r * &scale. + _origin_ ;
  128.         &risk.   = _cur_r - _cur_l ;
  129.         &lrisk.  = log ( &risk. ) ;
  130.         &fail.   = _fail_ * ( _exit_ eq _cur_r ) +
  131.                    &cens. * ( _exit_ gt _cur_r ) ;
  132.         _cint_   = not( _fail_ ) * ( _exit_ eq _cur_r ) ;
  133.         %if     &left.^= %then &left.     = _int_l ; ;
  134.         %if    &right.^= %then &right.    = _int_r ; ;
  135.         %if     &lint.^= %then &lint.     = _int_r - _int_l ; ;
  136.         %if  &os_left.^= %then &os_left.  = _int_l * &scale. + _origin_ ; ;
  137.         %if &os_right.^= %then &os_right. = _int_r * &scale. + _origin_ ; ;
  138.         %if  &os_lint.^= %then &os_lint.  = ( _int_r - _int_l ) * &scale. ; ;
  139.         %if     &cint.^= %then &cint.     = _cint_ ; ;
  140.         %if     &nint.^= %then &nint.     = _nint_ ; ;
  141.         output &out. ;
  142.      end ;
  143.      _cur_l = max ( _entry_, _break_ ) ;
  144.      _int_l = _break_ ;
  145.   end ;
  146.   next: ;
  147. run ;

  148. %mend Lexis ;
复制代码

使用道具

这是个什么宏?

使用道具

Arsaces 发表于 2016-9-15 23:43
是这个吗?
这是个什么宏?

使用道具

报纸
seanfang1992 发表于 2016-10-5 15:46:57 |只看作者 |坛友微信交流群
Arsaces 发表于 2016-9-15 23:43
是这个吗?
多谢帮助!真是一个忧桑的宏

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-20 07:47