Dear All, I have the following data
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id str12 country str32 all
1 "Singapore" "SingaporeThailandSingaporeBurma" 
1 "Thailand"  "SingaporeThailandSingaporeBurma" 
1 "Singapore" "SingaporeThailandSingaporeBurma" 
1 "Burma"     "SingaporeThailandSingaporeBurma" 
2 "Hong Kong" "Hong KongLaoMacauSingaporeTaiwan"
2 "Lao"       "Hong KongLaoMacauSingaporeTaiwan"
2 "Macau"     "Hong KongLaoMacauSingaporeTaiwan"
2 "Singapore" "Hong KongLaoMacauSingaporeTaiwan"
2 "Taiwan"    "Hong KongLaoMacauSingaporeTaiwan"
end
For each `id', I'd like to gather all the countries (Singapore, Thailand, Singapore, Burma for id=1) into a new variable called `all', as shown in the above data set . My code is
Code:
bys id: gen t = _n
reshape wide country, i(id) j(t)
egen all2 = concat(country*) 
reshape long country,i (id) j(j) 
drop if country == ""
drop j
My question is:
  1. Any other (more concise) way to do this?
  2. Is it possible to put a comma between countries in `all' variable?
Thanks in advance.