Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

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

Date |
Wed, 7 Nov 2012 21:29:32 +0000 |

There is a general discussion at SJ-7-4 dm0034 . . . Stata tip 52: Generating composite categorical variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/07 SJ 7(4):582--583 (no commands) tip on how to generate categorical variables using tostring and egen, group() .pdf at http://www.stata-journal.com/sjpdf.html?articlenum=dm0034 But your last remark rules that out. So why is #2 not working? Because by default your new variable is -float-. Make it -double- and read Bill Gould's blogs on precision every day until memorised! Nick On Wed, Nov 7, 2012 at 8:35 PM, Ben Hoen <bhoen@lbl.gov> wrote: > 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. * * 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/

**Follow-Ups**:**RE: st: Using tsset on panel data that are differentiated by two id variables***From:*"Ben Hoen" <bhoen@lbl.gov>

**References**:**st: Using tsset on panel data that are differentiated by two id variables***From:*"Ben Hoen" <bhoen@lbl.gov>

- Prev by Date:
**st: Stata connection to a DB2 using JDBC** - Next by Date:
**st: Translog cost function** - Previous by thread:
**st: Using tsset on panel data that are differentiated by two id variables** - Next by thread:
**RE: st: Using tsset on panel data that are differentiated by two id variables** - Index(es):