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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: Re: loop code problem |

Date |
Mon, 23 Mar 2009 22:24:00 +0100 |

<>

HTH Martin _______________________

To: <statalist@hsphsun2.harvard.edu> Sent: Monday, March 23, 2009 10:00 PM Subject: st: loop code problem

Hi statalisters:I can't figure out the correct coding to create a new variable"matchedname". My data was retrieved using propensity score matchingtechnique and it returned _id which is unique to each firm. Each firm alsohas an unique cusip number. The first three firms (atna, Sealaska, andaleut) were matched to three other firms (petrox, Oregon, and ripley). Iknow that from the _n1 column, which lists the matched company'sparticular id.What I am trying to do is create string variable "matchedname" that liststhe names of the three firms that were matched to the first threeobservations.Example of my data: Firm cusip _n1 _id matchedname atna 100 2569 9521 sealaska 101 4526 9823 aleut 104 325 357 petrox 10001 . 2569 oregon corp 10002 . 4526 ripley 10003 . 325I tried the following code, and it returned the same _n1 on thematchedname column instead:. gen matcheri=. (6 missing values generated) . gen matcherj=. (6 missing values generated) . gen matchernum=. (6 missing values generated) . forvalues i=1(1) 6 { 2. forvalues j=`i'(1) 6 {3. replace matcheri=1 in `i' if lister[`i']== id[`j'] & lister[`i']!=. &id[`j'] !=.4. replace matcherj=1 in `j' if lister[`i']== id[`j'] & lister[`i']!=. &id[`j'] !=.5. replace matchernum=lister[`i'] if lister[`i']== id[`j'] &lister[`i']!=. & id[`j'] !=.6. } 7. } What is wrong with this code? Thanks in advance. Ihsuan * * 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/

**Follow-Ups**:**st: RE: Re: loop code problem***From:*"Li, Ihsuan" <ihsuan.li@mnsu.edu>

**References**:**st: loop code problem***From:*"Li, Ihsuan" <ihsuan.li@mnsu.edu>

- Prev by Date:
**st: Counting** - Next by Date:
**st: Re: Counting** - Previous by thread:
**st: loop code problem** - Next by thread:
**st: RE: Re: loop code problem** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |