Dear all,
I use the TNIC data from Hoberg&Phillips and want to sort the scores pro competitor_rank1 in descending order in order to keep only the top 5 competitors for each gvkey1. I am not experienced with STATA and tried to do it using the following code, but the score is still in descending order:
clear
cd "C:\Users\etc"
use tnic3
sort gvkey1 score
gen competitor_rank = _n
sort competitor_rank gvkey1
egen competitor_rank1 = group(gvkey1)
bysort competitor_rank1 (score): gen descending_order = _n
sort competitor_rank1 -descending_order
alternative:
use tnic3
sort gvkey1 score
gen competitor_rank= _n
sort competitor_rank gvkey1
egen competitor_rank1=group(gvkey1)
sort -score competitor_rank1
(here the error is "- invalid name" even if the column is names "score")
Any help, however small would be greatly appreciated! Thank you in advance!
Related Posts with Order data in descending order
CI 95% generated by Meta set is slightly different than the CI generated by Metan codeI have been using STATA 14 for so long and I have run a lot of meta-analysis with no trouble. Recent…
multiple imputation (MICE) and varying estimation sample!Hello, I am building a regression model for ethnicity as a categorical exposure variable and death a…
Advice on suitability of panel design for studyHi all, I am under the impression that the panel format is not appropriate for my study and am stro…
precoin error 3301When I run precoin using the sample data of 100 obs, it works successfully. However , it doesn't wor…
Fixed Effects Regressions with Time and Individual Fixed EffectsHello, The following questions are to essentially check whether I am carrying out the correct econo…
Subscribe to:
Post Comments (Atom)
0 Response to Order data in descending order
Post a Comment