假設我有2個觀測和7個變量(其中表示遺漏值)數據集:塔塔:找到跨越變量重複不考慮遺漏值
crop1 crop2 crop3 crop4 nw1 nw2 nw3
3 7 2 . 3 7 .
5 9 . . 5 . .
現在我想找到的重複數Group1(crop1-crop4)變量和Group2(nw1-nw3)變量之間的值,通過生成一個名爲的新變量排除缺失的值。重複項。然後將新的數據集將是以下:
crop1 crop2 crop3 crop4 nw1 nw2 nw3 duplicates
3 7 2 . 3 7 . 2
5 9 . . 5 . . 1
因爲2的值(3,7)被發現重複用於第一觀察,和1倍的值(5)被發現,複製給所述第二觀察。
我可以用什麼樣的命令來獲取新的數據集?
你試過什麼代碼? –
也許是這樣的:make a row-number column,'gen id = _n'; '重塑長時間作業,我(id)j(組)';然後'複製標籤ID組,gen(d)' – Frank