Hello,
I'm working with a panel that has a variable that identifies the companies. I used encode to change the string variable into a categorical, however I'm struggling to handle the data now because I'm not being able to quickly identify what value is assigned to each company. I know that I can use br to check manually what value corresponds to each category, but I have 75 different companies and I need a more efficient way to check this. When I use the command 'tab' it displays all the categories but not the value assigned to them.
For example, I need to drop the observations from 11 companies. Is there any way to drop them using the tag instead of the numerical value assigned to these companies?
My dofile is the following:
clear
import excel "/Users/nicolasmorales/Downloads/Base Actualizada Entidades.xlsx", sheet("Base Consolidada") cellrange(A1:G19893) firstrow case(lower)
encode company, gen(company_temp)
drop company
rename company_temp company
sort company date
duplicates report company date
duplicates tag company date, gen(tag)
tab tag
drop if tag>0
* now, I need to drop the observations for 11 companies that are outliers. Is there an efficient way to do so?
tab entidad
*this displays the companies that I have, but not the values assigned to them in the categorical value
Thanks for the assistance
The dataset looks like this
company -- v1 -- v2 -- v3 -- ... -- vk date
Company_a -- 1 -- 2 -- 1 -- ... -- 1 2000
Company_a -- 0 -- 2 -- 1 -- ... -- 1 2001
Company B -- 0 -- 4 -- 2 -- ... -- 5 2000
....
Company Z -- ................................1 2019
There are 70 categories in the variable company and the dataset has 10,000 observations and information from the year 2000 to 2019.
Thanks for your assistance
Related Posts with Working with a categorical variable with many categories in a panel
help w r(103) error for reshaping dataHi, I'm trying to reshape a data set from wide to long but keep getting an error that there are too …
Type of RegressionHi, I want to model a regression for which the dependent variable is bounded from 0 to 1 (normally d…
Cross Section Data --> PanelI've been trying to aggregate my current data set into a panel format. Currently the data is a cross…
unifying the names of companies?Dear All, I have this data set. Code: * Example generated by -dataex-. For more info, type help dat…
Can asdoc output be exported as HTML?I would like to export asdoc (from SSC) or asdocx output as a HTML table? I searched the help files,…
Subscribe to:
Post Comments (Atom)
0 Response to Working with a categorical variable with many categories in a panel
Post a Comment