Statalist


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

AW: st: Re: Coding question: transactions panel dataset


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: Re: Coding question: transactions panel dataset
Date   Sat, 25 Apr 2009 18:33:26 +0200

<> 

Here is your code! I am giving you a string and an alternative as a numeric
variable to record the transaction, make your pick according to your
preferences :-)

*************
clear*

input  id year tract price white black hispanic 
1      1997 1 123 1 0 0
1 2000 1 145         0              1             0
2 1998 1 230         0              1             0
2 2001 1 236         0 1 0
2 2006 1 300 0 0 1
3 2002 3 250 1 0 0
3 2006 3 275 1 0 0
4 1998 2 235 0 0 1
4 2002 2 220 1 0 0
4 2006 2 245 0 1 0
end

compress

//difference in prices (in correct row)
bys id: gen diffprice=price[_n+1]-price[_n]

//use fact that dummies for owner evaluate to "true" if equal to "1"
gen str12 currentowner= cond(white,"white", cond(black, "black","hispanic"))
//get new owner
bys id: gen str12 newowner=currentowner[_n+1]

//transaction partners first option (string)
egen str20 transaction=concat( currentowner newowner)
//get rid of orphans at the end of the history of each property
bys id: replace transaction="" if _n==_N

//transaction partners second option (numeric)
egen transaction2=group( currentowner newowner)

//get rid of auxiliary variables
drop currentowner newowner

list, noobs  
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Marcus Casey
Gesendet: Freitag, 24. April 2009 23:56
An: [email protected]
Betreff: Re: st: Re: Coding question: transactions panel dataset

Hi Martin,

I apologize for my lack of clarity. I meant to type black-to-white  
sale.  For each repeat sale I wanted to construct an indicator of the  
type of sale i.e., whether the sale was white owner to black owner ,  
white owner to hispanic owner,etc. and for each of these transactions  
the difference in price.

For example, id represents a building. So in 1997 building 1 was  
bought by a white buyer  and in 2000 it was sold to a black buyer.   
Hence, we know that in 2000 we had a white-to-black sale and the  
difference between the price the white buyer paid and the black buyer  
paid is 145-123=22.


Thanks,

Marcus


On Apr 24, 2009, at 5:40 PM, Martin Weiss wrote:

> <>
>
> I do not quite get what you are asking for. Can you give an example  
> for say, a "black-white" transaction in your example data?
> Which "difference" are you referring to?
>
> Very generally, you want to use the fact that the -by- prefix  
> allows you access to each "id" separately, as described in Nick`s  
> canonical http://www.stata-journal.com/sjpdf.html?articlenum=pr0004
>
>
>
> HTH
> Martin
> _______________________
> ----- Original Message ----- From: "Marcus Casey" <[email protected]>
> To: <[email protected]>
> Sent: Friday, April 24, 2009 7:46 PM
> Subject: st: Coding question: transactions panel dataset
>
>
>> Hi,
>>
>> I have a question about an efficient coding scheme to calculate the
>> types of transactions over time in an unbalanced panel and
>> would appreciate a little help here.
>>
>> My dataset has the following structure:
>>
>>
>> id year tract price white black hispanic
>> 1      1997 1 123 1 0 0
>> 1 2000 1 145         0              1             0
>> 2 1998 1 230         0              1             0
>> 2 2001 1 236         0 1 0
>> 2 2006 1 300 0 0 1
>> 3 2002 3 250 1 0 0
>> 3 2006 3 275 1 0 0
>> 4 1998 2 235 0 0 1
>> 4 2002 2 220 1 0 0
>> 4 2006 2 245 0 1 0
>>
>>
>> I would code the following quantities for each id and,
>>
>> (1) a separate indicator for each transaction that labels whether it
>> is white-white, white-black, black-white, hisp-white, etc. and
>> temporal ordering.
>>
>> (2) the difference in transaction price for each type of transaction
>> described above.
>>
>> Thank you in advance for any assistance you can give me with this
>> problem.
>>
>> Regards,
>> Marcus
>>
>>
>> *
>> *   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/


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



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