Dear All, I found this question here (https://bbs.pinggu.org/thread-10294923-1-1.html). The raw data set is
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id str4 x
1 "A"
2 "B"
3 "C"
4 "" 
5 "" 
end
and the wanted data set is
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id str4 x
1 "A"
1 "B"
1 "C"
2 "A"
2 "B"
2 "C"
3 "A"
3 "B"
3 "C"
4 "A"
4 "B"
4 "C"
5 "A"
5 "B"
5 "C"
end
I have done this by
Code:
preserve
tempfile a
keep id
save "id", replace 
restore

tempfile b
keep x
save "x", replace 

cross using id
sort id x
order id
drop if x == ""
but wonder if there is a more way to do so? Thanks.