stata 将变量中所有值存为一个集合

levelsof variable,local (A)

levelsof 提取了variable下面每一个值,然后local把这些值统一在A的集合下面

. use tv1,clear

. des

Contains data from tv1.dta
 Observations:            10                  
    Variables:             6                  28 Dec 2009 12:10
-----------------------------------------------------------------------------------
Variable      Storage   Display    Value
    name         type    format    label      Variable label
-----------------------------------------------------------------------------------
kidid           float   %5.0f                 ID
dt              float   %d                    date of observation
female          float   %6.0f                 is kid female?
wt              float   %4.0f                 weight of kid
tv              float   %4.0f                 tv watching (in hours)
vac             float   %4.0f                 is kid on vacation?
-----------------------------------------------------------------------------------
Sorted by: 

. levelsof dt ,local(a)
15347 15348 15350 15351 15353 15356 15358 15359 15361 15362
. levelsof female ,local(b)
0 1

 

posted @ 2023-04-12 16:26  myrj  阅读(156)  评论(0编辑  收藏  举报