Statalist The Stata Listserver


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

RE: st: data formatting question


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: data formatting question
Date   Tue, 14 Feb 2006 01:42:33 -0000

It seems that "without success" is a new variant on that 
old Statalist standby "doesn't work"! You don't say 
what you mean by it. 

These are all legal commands if the data have
been sorted previously by -countrynumber-. 

But the first says: within categories of 
-countrynumber-, -gen new_var- with 
values of 0. You might as well have said 

gen new_var == 0 

as the -by:- prefix makes no difference
to the result. 

The same comment applies to the second. 

Please specify a numerical example showing 
what you want. 

Nick 
[email protected] 

Andy Choi
 
> Using this same example from previous emails is there
> a command that would sort by country number when
> defining a new variable?
> 
> For example, I have tried something like this without
> success:
> by countrynumber: gen new_var=0
> by countrynumber: replace new_var=1 if year=="1930" &
> ethnicity=="Hispanic"
> I want the end result to be 0 or 1 for each unque
> country number value.  
> 
> 
> > 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
> > 

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