如題,我有一個所得變數,想要區分為3級,例如:
if 0萬-100萬, then Inc=1
if 101萬-200萬, then Inc=2
if 201萬-300萬, then Inc=3
其中Inc是新建立的變數,有人知道語法要如何下嗎?
※ 編輯: incessantgas 來自: 140.109.122.224 (05/31 17:33)
if 0萬-100萬, then Inc=1
if 101萬-200萬, then Inc=2
if 201萬-300萬, then Inc=3
其中Inc是新建立的變數,有人知道語法要如何下嗎?
※ 編輯: incessantgas 來自: 140.109.122.224 (05/31 17:33)
推 fox817:你可以直接在檔案裡內建阿,就data set裡新設這個變數就好 05/31 22:34
→ fox817:這就類似在數據資料裡再另設有程度區分的dummy 05/31 22:36
推 davedave91:小弟我只會土法煉鋼法 您如果不介意就參考一下吧 06/01 00:00
→ davedave91:gen inc=1 if income>=0 &income<=1000000 06/01 00:00
→ davedave91:replace inc=2 if income>1000000 &income<=2000000 06/01 00:01
→ davedave91:replace inc=3 if income>2000000 & income<=3000000 06/01 00:03
→ incessantgas:謝大家幫忙。但我依稀記得看過類似的指令(在UCLA的 06/01 15:00
→ incessantgas:教學網站),好像可以直接寫(xx-xx)給1,(xx-xx)給2 06/01 15:01
→ incessantgas:以此類推 06/01 15:01
→ incessantgas:剛剛找到解答了,上來分享一下... 06/06 12:37
→ incessantgas:reocde Inc (0/100=1) (101/200=2) (201/300=3), 06/06 12:38
→ incessantgas:gen(IncCat) 06/06 12:38
All Comments