今天写程序用到很多replace命令,但是有的地方replace var1=0 if var2>=5这样的程序就可以用;有的地方就不能用。不明白为什么?
使用help replace,里面都是讲replace 和 generate的区别,也没解决我的问题。
举个例子,10个国家的数据(state value=1~10),想新建个分区变量:district(1~4),用下面的命令,为什么跑不动?
gen district=.
replace district=1 if state=2,3,4
replace district =2 if state=1
replace district =3 if state=5,6,9
replace district =4 if state=7,8,10
【两个变量都是double型】
尝试过用不同的方法写 if 后面的命令,但是都不work。这样比起来,感觉sas就很容易实现了.....哭晕......
求大牛指点一二,快来救我~~


雷达卡




京公网安备 11010802022788号







