Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: simple list of panel data...


From   Marcello Pagano <[email protected]>
To   [email protected]
Subject   st: Re: simple list of panel data...
Date   Sun, 21 Jan 2007 10:26:02 -0500

From: Kit Baum <[email protected]>
Date: January 21, 2007 10:09:17 AM EST
To: [email protected]
Subject: simple list of panel data...


Tom said

What I still could not solve is how to integrate string variables here,
especially regarding the -collapse- process.

I.e. showing the respective "country" or another variable that is filled
with strings. Sorry if I'm overlooking something obvious.


Not a problem:

webuse grunfeld,clear
lab def comp 1 A 2 B 3 C 4 D 5 E 6 F 7 G 8 H 9 I 10 J
lab val company comp
g y50 = (year==1950)
bys company: gen inv50=sum(y50*invest)
tsspell,c(invest>L.invest)
egen nspell=max(_spell),by(company)
collapse (sum) inv50 (mean) nspell (count) year, by(company)
list
outsheet using tom.txt, replace noquote
type tom.txt

As the company names are tab-delimited, you do not need quotes, even if they include commas and spaces in their names.

In order to make a numeric variable out of company name (with its name as its label), use -encode-, and use the new variable created by encode as the by-variable in the collapse.



Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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