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]

st: Using tsset on panel data that are differentiated by two id variables


From   "Ben Hoen" <[email protected]>
To   <[email protected]>
Subject   st: Using tsset on panel data that are differentiated by two id variables
Date   Wed, 7 Nov 2012 15:35:22 -0500

Hi all, 

I have run into problems setting a set of data as panel because my panels
are differentiated by two numeric ids (muni_code %8.0g & parcel_id %12.0g)
both with values 1 to 999,999. For example I might have the following cases.

muni_code         parcel_id
22000             59
22000             60           
22000             600
22000             601
27600             32199

Because I cannot use a var list (at least I don?t think I can) as panel
variables in tsset, I would like to combine the variables while also
preserving the ids so that they are both usable as a merge variable and are
descriptive in their values.  So, for example, I tried:

1) Using tostring to make a variable (muni_parcel_text) that looked like
this ?22000.59? ?22000.60? ?22000.600?, ?22000.601?  and ?22000.5983? and so
on but the tsset wont accommodate a string variable

2) I then tried using the following formula .g muniparcel=(muni_id*100000) +
parcel_id, which I then formatted as %12.0f (.format muniparcel %12.0f) but
strangely got weird values such as 22000060, 2200000000, 2200000000,
22000000512 and 2200000512, and 2760032256, respectively.  I would have
expected to get 22000000059, 22000000060, 22000000600, 22000000601, and
27600032199, respectively.

Any idea how to how best to use these two variables as a panel variable,
while preserving their values in some way?   Seperately, any idea why option
#2 is not resulting in the expected answer?


FYI, for one file, I could just use .egen muniparcel=group(muni_code
parcel_id) and use muniparcel as the panel variable, but then I would not be
able to merge with another dataset because the group numbers would not
necessarily align.

As always, thanks for your input/suggestions.

Ben




Ben Hoen
Principal Research Associate
Lawrence Berkeley National Laboratory
Office: 845-758-1896
Cell: 718-812-7589
[email protected]
http://emp.lbl.gov/staff/ben-hoen

Visit our publications at: 
http://emp.lbl.gov/publications





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