楼主: mayyyy
2752 4

[数据管理求助] stata创造一个二值变量(0,1)然后规定他的均值为0.7怎么做呢 [推广有奖]

  • 0关注
  • 0粉丝

小学生

7%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
59 点
帖子
5
精华
0
在线时间
0 小时
注册时间
2015-6-22
最后登录
2016-11-15

楼主
mayyyy 发表于 2016-10-9 05:54:04 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
stata创造一个二值变量(0,1)然后规定他的均值为0.7怎么做呢
二维码

扫码加我 拉你入群

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

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

关键词:Stata tata 怎么做

沙发
夏目贵志 发表于 2016-10-9 08:30:57
clear
set obs 1000
gen x=(_n<=700)
su x

藤椅
mayyyy 发表于 2016-10-11 03:21:56
夏目贵志 发表于 2016-10-9 08:30
clear
set obs 1000
gen x=(_n
确实解决了问题,不过可否问一下  "_n"  是什么意思?

板凳
夏目贵志 发表于 2016-10-11 07:09:33
mayyyy 发表于 2016-10-11 03:21
确实解决了问题,不过可否问一下  "_n"  是什么意思?
当前观测值的序号

报纸
蓝色 发表于 2016-10-11 07:27:23

遇到不懂查stata软件的help


Title

    [U] 13.4 System variables (_variables)


Description

    Expressions may also contain _variables (pronounced "underscore variables").  These are built-in
    system variables that are created and updated by Stata.  They are called _variables because their
    names all begin with the underscore (_) character.

    The _variables are

    [eqno]_b[varname] (synonym:  [eqno]_coef[varname]) contains the value (to machine precision) of the
        coefficient on varname from the most recently fitted model (such as ANOVA, regression, Cox, logit,
        probit, and multinomial logit).  See [U] 13.5 Accessing coefficients and standard errors for a
        description.

    _cons is always equal to the number 1 when used directly and refers to the intercept term when used
        indirectly, as in _b[_cons].

    _n contains the number of the current observation.


    _N contains the total number of observations in the dataset.

    _pi contains the value of pi to machine precision.

    _rc contains the value of the return code from the most recent capture command; see [P] capture.

    [eqno]_se[varname] contains the value (to machine precision) of the standard error of the coefficient
        on varname from the most recently fit model (such as ANOVA, regression, Cox, logit, probit, and
        multinomial logit).  See [U] 13.5 Accessing coefficients and standard errors for a complete
        description.

    The _n and _N variables are useful for indexing observations or generating sequences of numbers.  _n
    can act as a running counter within a by-group and _N acts as the total number within each by-group.

    _rc is useful for programmers, particularly if you want to test a command internal to a program
    without having the program terminate.


Examples

    . display _pi
    . display cos(_pi)
    . range x 0 4*_pi 100

    . sysuse auto, clear
    . generate price2 = price[_n-1]
    . regress price mpg foreign rep78
    . display _b[mpg]

    . mlogit rep78 gear_ratio displacement foreign
    . display [5]_b[foreign]

    . webuse dollhill2, clear
    . by age (smokes), sort: generate wgt=pyears[_N]


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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-24 12:54