stata中变量的使用

2025-07-04 07:30:26

1、用list make weight 显示数据

stata中变量的使用

2、尝试执行 gen weight=weight/1000,系统提示变量已存在

stata中变量的使用

3、用replace命令replace weight=weight/1000

stata中变量的使用

4、如果foreign==0,将price提高5%,如果foreign==1,将price提高10%。 gen predprice=1.05*price if foreign==0 和replace predprice=1.1*price if foreign==1 再显示结果list make foreign price predprice

stata中变量的使用

5、list中nolabel参数的使用。list make foreign price predprice,nobel步骤4中foreign 显示为domestic和foreign,而步骤5中foreign 显示为0和1

stata中变量的使用

6、gen where ="D" if foreign=="Domestic":origin replace where ="F" if foreign=="Foreign":origin 如果foreign的值为domestic则where的值为D,否则where的值为F

stata中变量的使用

7、显示自定义变量.list make foreign where

stata中变量的使用

8、显示where变量的详细信息

stata中变量的使用

9、定义model变量和modelwhere变量 gen model =usubstr(make,ustrpos(make,"")+1,.) gen modelwhere =model +" " + where

stata中变量的使用

10、显示model变量和modelwhere变量的值。 list make where model modelwhere

stata中变量的使用
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢