楼主: runman
5924 3

[数据管理求助] replace..if...操作时候stata为什么也会对空值进行赋值 [推广有奖]

学科带头人

77%

还不是VIP/贵宾

-

威望
0
论坛币
2252 个
通用积分
27.5974
学术水平
8 点
热心指数
9 点
信用等级
8 点
经验
51532 点
帖子
979
精华
0
在线时间
3793 小时
注册时间
2010-4-3
最后登录
2025-11-24

楼主
runman 发表于 2016-8-4 16:44:22 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
比如我想将变量abc大于100的值,都替换为100,其中500,600之间是有2个数值是缺失的
abc

1

2

3

4

500

600

120

10

11

12

13

14

15

在输入命令:replace abc = 100 if abc >= 100 后,结果发现“空值”也被赋值为100,不想对空值进行任何操作,该怎么处理呢?
运行结果:

. replace abc = 100 if abc >= 100
(5 real changes made)


abc
1
2
3
4
100
100
100
100
100
10
11
12
13
14
15




二维码

扫码加我 拉你入群

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

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

关键词:replace Stata place tata PLA replace

回帖推荐

蓝色 发表于3楼  查看完整内容

replace abc = 100 if abc >= 100 & abc~=.

蓝色 发表于2楼  查看完整内容

看帮助解释缺失值 Title 12.2.1 Missing values Description Stata has 27 numeric missing values: ., the default, which is called the "system missing value" or sysmiss and .a, .b, .c, ..., .z, which are called the "extended missing values". Numeric missing values are represented by large positive values. The ordering is all non ...

沙发
蓝色 发表于 2016-8-4 17:25:25
看帮助解释缺失值

Title

    [U] 12.2.1 Missing values

Description
    Stata has 27 numeric missing values:
        ., the default, which is called the "system missing value" or sysmiss
    and
        .a, .b, .c, ..., .z, which are called the "extended missing values".

    Numeric missing values are represented by large positive values.  The
    ordering is

                 all nonmissing numbers < . < .a < .b < ... < .z

    Thus, the expression age > 60 is true if variable age is greater than 60 or missing.

    To exclude missing values, ask whether the value is less than ".".  For instance,

        . list if age > 60 & age < .

    To specify missing values, ask whether the value is greater than or equal to
    ".".  For instance,
        . list if age >=.
    Stata has one string missing value, which is denoted by "" (blank).


藤椅
蓝色 发表于 2016-8-4 17:28:53
replace abc = 100 if abc >= 100  & abc~=.
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
日新少年 + 1 + 1 + 1 精彩帖子

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

板凳
runman 发表于 2016-8-4 19:38:46
蓝色 发表于 2016-8-4 17:28
replace abc = 100 if abc >= 100  & abc~=.
非常感谢

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

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