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: 1:1 match and identifying result
From
Steve Samuels <[email protected]>
To
[email protected]
Subject
Re: st: 1:1 match and identifying result
Date
Fri, 27 Apr 2012 08:50:50 -0400
Very nice!
-cem- from SSC would also allow exact matching on some factors.
Steve
[email protected]
On Apr 26, 2012, at 6:28 PM, Stas Kolenikov wrote:
On Thu, Apr 26, 2012 at 4:17 PM, uniseminar uniseminar
<[email protected]> wrote:
> Hi all,
>
> My - beginners - problem concerns the 1:1 matching of a treated group
> of companies to an untreated by three variables. Two of the
> variables need to be exact matches and one should be in a range of 25%
> difference. All numeric: founding year, target year, sales.
> my data looks similar to this:
> Company1 target-year1 sales1 founding-year ID1 ...
> Company1 target-year2 sales2 founding-year ID2 ...
> ...
> Company2 target-year1 sales1 founding-year IDx+3...
> Company2 target-year2 sales2 founding-year IDx+4...
> ....
>
> I tried to work on several matching procedures with merge, vmatch,
> psmatch2 nnmatch etc. Neither was suitable for me...
> vmatch was matching the three variables, but does not give me the
> unique identifier of the matched company next to the treated company.
> Further question: If I would receive the ID of the matched comp in the
> line of the treated comp(thats the goal), how can I make sure to
> compare these two? Something like: if ID of matched is found under
> another variable in another line of treated comps then subtract sales
> treated from sales matched...
>
> Hopefully this is understandable...!?
Brute force solution that employs the exact equality:
sysuse auto
ren foreign treated
ren mpg year1
ren head year2
replace year2 = 10+2*year2
replace year1 = floor(year1/2)
egen same_years = group( year1 year2 )
bysort same_years (price ) : gen byte match_prev = reldif( price,
price[_n-1] ) < 0.25 & (treated + treated[_n-1] == 1)
bysort same_years (price ) : gen byte match_next = reldif( price,
price[_n+1] ) < 0.25 & (treated + treated[_n+1] == 1)
list if match_prev == 1 | match_next == 1 , sepby(same)
--
Stas Kolenikov, also found at http://stas.kolenikov.name
Small print: I use this email account for mailing lists only.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/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/statalist/faq
* http://www.ats.ucla.edu/stat/stata/