I’m attempting to list distinct values where a second variable satisfies a certain condition.
I’m trying to implement the advice “After using egen, tag() to create a tagged variable, you can list tagged observations to again show the distinct combinations.” from Speaking Stata: Distinct observations, The Stata Journal (2008), 8, Number 4, pp. 557–568 (on page 11 of my pdf version of the article)
Here’s an attempt using the auto file – ie listing distinct car makes where they are foreign.
but I don’t know how to set the list command to list the makes which have now been tagged?
I can see the end goal with the bysort command, eg
bysort foreign: list make
however, the eventual data file I’ll be analysing has a tens of thousands of unique variables and only a small number of distinct variables to be listed.
I hope this makes sense, thank you for reading through the problem, Dan
I’m trying to implement the advice “After using egen, tag() to create a tagged variable, you can list tagged observations to again show the distinct combinations.” from Speaking Stata: Distinct observations, The Stata Journal (2008), 8, Number 4, pp. 557–568 (on page 11 of my pdf version of the article)
Here’s an attempt using the auto file – ie listing distinct car makes where they are foreign.
Code:
* list unique make with foreign attribute clear sysuse auto egen tag = tag(foreign make) egen nvals = total(tag), by(foreign) tabdisp foreign, cell(nvals)
I can see the end goal with the bysort command, eg
bysort foreign: list make
however, the eventual data file I’ll be analysing has a tens of thousands of unique variables and only a small number of distinct variables to be listed.
I hope this makes sense, thank you for reading through the problem, Dan
Comment