Bookmark and Share

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]

RE: st: Improve matching


From   "Seliger Florian" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: Improve matching
Date   Wed, 22 May 2013 14:19:45 +0000

Thank you Nick for reading through my problem and your answer!




-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Freitag, 17. Mai 2013 17:42
To: [email protected]
Subject: Re: st: Improve matching

gen namelength = length(trim(firm))
bysort id (namelength) = trim(firm[_N])

Then if all is well

by id : keep if _n == _N

I threw in trimming of leading and trailing spaces too.

(For "STATA" read "Stata".)
Nick
[email protected]


On 17 May 2013 16:20, Seliger  Florian <[email protected]> wrote:
> Dear Statalist,
>
> I want to improve matching of two datasets. I use a matching software, but want to prepare the datasets with STATA.
> One dataset is in panel structure, i.e. I have multiple observations per ID:
>
> ID           firm
> 314         POLYTYPE
> 314         POLYTYPE  MASCHINENFABRIK
> 314         POLYTYPE  NA
> 314         POLYTYPE
> 314         POLYTYPE
> 314         POLYTYPE
>
> The length of the firm name may vary across IDs.
> I noticed that it is necessary to keep only the ID with the LONGEST NAME, in this case "POLYTYPE MASCHINENFABRIK".
> It is necessary to delete all other IDs for the same observation to enable a proper matching (due to the software).
>
> Any suggestions how I could only keep the LONGEST NAME IDs (each observation has different names, and within each observation each ID has different names, there is no regularity) in STATA?
>
> Thank you for your consideration.
>
> Best,
> Florian
>
> *
> *   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/
*
*   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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index