Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: psmatch2 with the if condition

From   "Dr. Roberto Mura" <>
Subject   st: psmatch2 with the if condition
Date   Mon, 22 Mar 2010 09:53:56 +0000

Dear all, I have a cross sections of companies, some listed some private.
I am trying to find a matching private (undiversified) firm for each listed one, on the basis of company size. Also, since my dataset is cross country, I am trying to control for country and sic code as well. To this end, I have created a condition, called condition1 to divide the sample into a set of clusters: catenate condition1 = country sic2 Now, once a match is found, I need Stata to report some accounting data for the matched private firm on the same row as the listed firm. I have tried to create a "self-fulfilling" nested loop so that I don't need to specify beforehand the total number of clusters (condition1) and also because the total number of firms changes with different clusters (Ncondition1 below). The problem that I am facing is that psmatch2 does not seem to understand the "if" condition. I have uploaded the dataset (for version 11 and for version 9 of Stata) and the do file in my website under if you want to take a look.
Here is what I do:

use "D:\AAA.dta", clear
catenate condition1 =  country sic2
gen quotedcondition1=1 if quotedcompany==1
replace quotedcondition1=0 if quotedcompany==0 & diversification_orig==1
gen quotednumerator=.
gen quoteddenomenator=.
gen privatenumerator=.
gen privatedenominator=.
egen g=group(condition1)
bysort condition1: gen Ncondition1=_N

local j=1
while `j' <=g {
psmatch2 quotedcondition1 if g==`j', pscore(size) noreplacement
replace quotednumerator=fnetincome if _nn==1
replace quoteddenomenator=shareholdersfundsnew if _nn==1
replace privatenumerator=fnetincome if _n1==_id
replace privatedenominator=shareholdersfundsnew if _n1==_id

local i=1
while `i' <Ncondition1 {
replace privatenumerator=fnetincome[_n+`i'] if _n1==_id[_n+`i']
replace privatedenominator=shareholdersfundsnew[_n+`i'] if _n1==_id[_n+`i']
replace privatenumerator=fnetincome[_n-`i'] if _n1==_id[_n-`i']
replace privatedenominator=shareholdersfundsnew[_n-`i'] if _n1==_id[_n-`i']
local i = `i' + 1
local j = `j' + 1

The problem seems to lie in
psmatch2 quotedcondition1 if g==`j', pscore(size) noreplacement
What seems to be happening is that the matching is done only for the first 3 firms of the first cluster and then Stata is mis-assigning the _id since the numbers do not follow the clustering but rather, Stata is applying the psmatch2 considering the sample as a whole. If, for instance, I change the if condition into:
psmatch2 quotedcondition1 if g==1, pscore(size) noreplacement
then Stata is not matching inside the cluster (condition1) but again it is treating the sample as a whole. In other words the "if" condition does not appear to be used at all by Stata.

I have tried both version of psmatch2. The one available trough SSC (version 3.1.5 2may2009) and the more recent one available from (4.0.1) I have Stata/MP 11.0 for Windows (64-bit x86-64) running on XP Pro 64. I also tried with the older version I had, Stata/SE 9.2 for Windows 64-bit x86-64and things don't change.
Thank you all for your kind attention
Kind regards

Dr. Roberto Mura, Ph.D.
Assistant Professor of Finance
Program Director for MSc in Finance and Economics
Program Director for MSc in Finance and Business Economics
The Manchester Accounting & Finance Group
Manchester Business School
home page:

*   For searches and help try:

© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index