在《A Handbook of Statistical Analyses using Stata, 4th edition》一书的第6.3.1节(第116页)中,作者利用egen命令分别创建了两个新变量
...
egen therapy = seq() , from(0) to(1) block(2)
egen sex = seq() , from(1) to(2) by(therapy)
label define t 0 seq 1alt
label values therapy t
label define s 1 male 2 female
label values sex s
查看 help egen 中有关 seq() 的介绍,我明白了这个命令所生成的新变量时一个取值从from(#) to(#) 的整数序列,不过对于block(#)选项,我就没弄懂。帮助中的意思是block()选项是用于设定observations的分块的,但是仅仅设定分成几块,而没有说明如何分块,对于这个命令所生成的新变量的取值会产生什么影响呢?
故此,向各位坛友请教!
-------------------------------------------------------
补充:help egen 中 关于 seq() 的说明文字
seq() [, from(#) to(#) block(#)] (allows by varlist:)
returns integer sequences. Values start from from() (default 1) and increase to
to() (the default is the maximum number of values) in blocks (default size 1). If
to() is less than the maximum number, sequences restart at from(). Numbering may
also be separate within groups defined by varlist or decreasing if to() is less
than from(). Sequences depend on the sort order of observations, following three
rules: 1) observations excluded by if or in are not counted; 2) observations are
sorted by varlist, if specified; and 3) otherwise, the order is that when called.
No arguments are specified.