Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: RE: Re: Delete companies based on observations
From
Amy Dunbar <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: RE: Re: Delete companies based on observations
Date
Wed, 13 Nov 2013 13:04:10 +0000
Nick's command deletes directly, which is more efficient. I create a panel variable using the egen function when I work with Compustat data.
bysort cik: egen pdata=count(fyear)
where cik is the company identifier and fyear is based on fiscal year end. Then I delete based on the pdata value that I want in my dataset.
Amy Dunbar
UConn
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of M@rk
Sent: Wednesday, November 13, 2013 5:23 AM
To: [email protected]
Subject: st: Re: Delete companies based on observations
Dear Nick,
That is indeed what I meant. Thanks for your help! Now I am able to proceed with my research.
Kind Regards,
Mark Krap
-----Oorspronkelijk bericht-----
From: Nick Cox
Sent: Wednesday, November 13, 2013 11:08 AM
To: [email protected]
Subject: Re: st: Delete companies based on observations
Various errors here:
1. -drop- doesn't support a -by()- option: if it did, that would be documented.
2. There is no -count- function in Stata. Perhaps you mean the -count- command. (-egen- supports a -count()- function, here meaning
(confusingly) an -egen- function, not a Stata function.)
3. _n only ever refers to observation identifiers in sequence; you want _N.
4. -comnam[_n]- is the current value of -comnam-, not its frequency of occurrence.
That said,
bysort comnam : drop if _N <= 13
is what you want.
Nick
[email protected]
Mark Krap
> I need to delete all companies of which I have equal or less than 13
> observations. I already tried the following commands, without the
> desired result.
>
> drop if _n<=13, by(comnam)
>
> drop if comnam[_n]<=13
>
> I assume that the count funtion in Stata can help me to delete these
> companies, but I do not know how to incorporate this in a command in
> order to do the deletions.
*
* For searches and help try:
* http://cp.mcafee.com/d/avndzgw921J5BVxBBVdZYTsSOejsKed7a9JAsCVtVxUSOejsKed7b9JAsCUqemkn3uGBKgrwgS8a8dQB3WkVKRogXQ6Pp1KAEviDdSH27uwSrZxBZBVd_HYOyOU_sQsZuVt4QsFLYMUMqerLIYJteOaqJQQ-l3PWApmU6CQjrxK_nhh7ec3HLCzATsS02FfpXO-4_fmU12lfSdypKAZDFYGjbRcg-8a9Qm9QrwDNfoCtyxTEdCS6kPhOrFd8Qg0LQzh07uvY_d42WSMBZ3h0gSDE6y2I3h1kxjUCtDaIa6XCRvG_
* http://cp.mcafee.com/d/1jWVIi418edEILccIL9LLCXCShOrBNNEVhdIzATbLcf6ShOrBNNEVpdIzAT3hOOyUrRkJO3s26N1h1KAEviDdSH27uwSr8dQB3WkVKRogXQ6PvIcLIL9LZvCkmn7XCzDHTbECzBd_C763hPtZDBHFShjlKCDOEuvkzaT0QSCrsdTWWa8VNwttYQsCXCM0l9XfunOzqORoPNThqCh-BmUS-CkDIZfBiptThr3t9XfjVkCnGoxYgkjEIjET1fyuNcX53LgrdIcFCzATiqhEw1vF6y0eY_V-q85RJxbW6y0xJfgd45o6y2F2DNcXelokdTdLHnaGCx5fitF
* http://cp.mcafee.com/d/FZsSd1MA86QmnC6mnATTPtPr8VdOUUQsECShOrBTC7zr8VdOUUQsICShOrxEVphsdWGmV1K13owEwTikfFjCXlx3LgrdA6WixZasTqI8tW3pLS6nSnAT-LPabbzZPhPRXBQjhOC_P3z1EVK-PORQX8FGTjjVkffGhBrwqrpdK6XZt54sUMeK-qejtPo0bpQVKN-ZW3ukDIYFfpXxKAZDFYGjbRcg-8a9Qm9QrwDNfoCtyxTEdCS6kPhOrFd8Qg0LQzh07uvY_d42WSMBZ3h0gSDE6y2I3h1kxjUCtDaIa6XCRGCe
*
* For searches and help try:
* http://cp.mcafee.com/d/k-Kr43qbbP3bbOrXVKVJAsCVssqekjr8VdOXP3NJAsCVssqemjr8VdMQsIEK6ZlbswT0xIgkgrFa7QFPtGMxTEdCO3t9g-BerJm4eZ1ITX3bXbOr_nVB5BN-VEVWZOW9EVjvVxNwQsTvpVqWtAkRrFFYG7DR8OJMddI6T3t-Kyyeso7nvd79KVI05iuPTBY9-uJM24GvIr4Pt9XfjVkCnGoxYgkjEIjET1fyuNcX53LgrdIcFCzATiqhEw1vF6y0eY_V-q85RJxbW6y0xJfgd45o6y2F2DNcXelokdTdBo7y
* http://cp.mcafee.com/d/2DRPoO91MAcCQmnC6mnATTPtPr8VdOUUQsECShOrBTC7zr8VdOUUQsICShOrxEVphsdWGmV1K13owEwTikfFjCXlx3LgrdA6WixZasTqI8tW3pLS6nSnAT-LPabbzZPhPRXBQjhOC_P3z1EVK-PORQX8FGTjjVkffGhBrwqrvdK6XZt54sUMeK-qejtPo0aAZDLbVhJpqIpUXEJj8_iHsrvjajSuDOFcKXEJxKAZDFYGjbRcg-8a9Qm9QrwDNfoCtyxTEdCS6kPhOrFd8Qg0LQzh07uvY_d42WSMBZ3h0gSDE6y2I3h1kxjUCtDaIa6XCQPRJbm2GfbCi
* http://cp.mcafee.com/d/k-Kr6x0p6hASyOYMOOYC--rKrp79Kn76zB4SOejsKYMYrp79Kn76zBASOejsd7babxLliT8dM8r4546WixZasTqI8tW3pIwTikfFjCXlx3Lgrd-MO-OYC_R-phpsvKqeuLsKyqekT-osod7dTSumKDp5dmWqvaxVZicHs3jrxJMTvHEEzD61RTPhOrKr01reDdSfTLgrOAZDB9XfsdQDIZfBipuFy7N1heyNezs4-9X4PIkeZ1ISMOCqejt9F6y05-Aq80XP_DVEwnmS4LEq826QZ0Qglwq8aAav4PIVlxgTsSKsS9Sx6sZ8_
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/