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
Change date variable to one stata can readHello Statalist, I've a question regarding my dataset. I want to extract the year and month separat…
Different marginal effect for dummy variable after logit, depending on using i-prefix or notHello, I'm wondering why margins (after logit) produces different results for a dummy variable (0-1…
twopm: Two Part ModelsI am using Stata 15 MP and my analytic data set is a geographic region-year panel, for the years 200…
gologit2 suddenly having problems in Stata 15I have sent this problem to Stata tech support. I will be amazed if anyone on the list can help me b…
Merging few observations to copy/add for other observationsHello, I am relative to Stata and I just cannot figure out how to solve the following problem. My m…
Subscribe to:
Post Comments (Atom)
0 Response to Order data in descending order
Post a Comment