Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Presenting a country-period table


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Presenting a country-period table
Date   Thu, 1 Apr 2004 20:29:03 +0100

The result of this 

egen When = concat(periodstart periodend), p("-") 
gen when = "" 
bysort country (When) : replace when = when[_n-1] + When + "," if _n < _N 
by country : replace when = when[_n-1] + When if _n == _N 
by country : gen last = _n == _N 
list country when if last, noobs sep(0) 

is this

  +-----------------------------------------------------+
  |   country                                      when |
  |-----------------------------------------------------|
  | Argentina   1986-1989,1990-1993,1994-1997,1998-2001 |
  |   Bolivia   1986-1989,1990-1993,1994-1997,1998-2001 |
  |  Botswana             1974-1977,1978-1981,1982-1985 |
  +-----------------------------------------------------+

You can also left-justify via -format-. Any use? 

Nick 
[email protected] 

Jan Pettersson

> I have a list of the following form:
> 
> country periodstart periodend
> Argentina 1986 1989
> Argentina 1990 1993
> Argentina 1994 1997
> Argentina 1998 2001
> Bolivia 1986 1989
> Bolivia 1990 1993
> Bolivia 1994 1997
> Bolivia 1998 2001
> Botswana 1974 1977
> Botswana 1978 1981
> Botswana 1982 1985
> etc.
> 
> that I would like to present in a table looking like:
> 
> Argentina (1986 - 1989, 1990 - 1993, 1994 - 1997, 1998 - 2001);
> Bolivia (1986 - 1989, 1990 - 1993, 1994 - 1997, 1998 - 2001);
> Botswana (1974 - 1977, 1978 - 1981, 1982 - 1985);
> etc.
> 

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