Statalist The Stata Listserver


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

st: RE: data formatting question


From   "Salvati, Jean" <[email protected]>
To   <[email protected]>
Subject   st: RE: data formatting question
Date   Mon, 13 Feb 2006 16:16:30 -0500

You could try something like this:

separate ethnicpop, by(ethnicity) gen(pop)

/* here you may want to rename the variables created by separate, called
pop1 and pop2 for now */

collapse (mean) pop1 pop2, by (Country_Number year)

Hope this helps.

Jean Salvati

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> Michael Horowitz
> Sent: Monday, February 13, 2006 3:31 PM
> To: [email protected]
> Subject: st: data formatting question
> 
> To whom it may concern:
> 
> I have a dataset I was wondering if people might have a fix for.
> 
> My data measures various information (ethnicity especially) 
> of countries.  The way the data is currently set up it has 
> multiple entries per country per year depending on the 
> background of the country.  This means that if there are 2 
> ethnic groups in a country with significant populations, 
> there are 2 entries per year as follows (these numbers are 
> made up to illustrate the situation).  There can also be more 
> than 2, etc., and it can change depending on the population 
> in a given year:
> 
> Country Number	year	ethnicity	ethnicpop
> 10		1930	Caucasion	1,000,000
> 10		1930	Hispanic	50,000
> 10		1931	Caucasion	1,000,100
> 10		1931	Hispanic	51,000
> 11		1931	Asia		10,000
> 
> 
> I want to set up the data so there is only one entry per 
> country per year, as follows:
> 
> Country Number	year	ethnic1	   ethnic2   ethpop1    ethpop2
> 10		1930	Caucasian  Hispanic  1,000,000	50,000
> 
> Any ideas people have would be greatly appreciated.
> 
> Sincerely,
> Michael Horowitz
> *
> *   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/
> 

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