Statalist


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

st: RE: RE: copy values


From   "Victor, Jennifer Nicoll" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: RE: copy values
Date   Thu, 11 Dec 2008 14:50:13 -0500

Thanks.  The following command worked perfectly.  Sorry I didn't look for it in the FAQs.

replace blackstate = blackstate[_n-1] if blackstate >= .

___________________________________________
Jennifer Nicoll Victor
Assistant Professor
Department of Political Science
University of Pittsburgh
4600 Wesley W. Posvar Hall
(412) 624-7204
E-mail:  [email protected]
Homepage:  http://www.pitt.edu/~jnvictor


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Thursday, December 11, 2008 2:40 PM
To: [email protected]
Subject: st: RE: copy values

This is an FAQ. 

FAQ     . . . . . . . . . . . . . . . . . . . . . . . Replacing missing
values
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N.
J. Cox
        2/03    How can I replace missing values with previous or
                following nonmissing values?
                http://www.stata.com/support/faqs/data/missing.html

-- apart from the twist about -drop-ping values which is standard stuff.


I may be in a minority, but I dislike signals of "Thanks in advance".
Courtesy is not the issue here; people who ask questions acquire the
responsibility to report on what worked and close a thread. 

Nick 
[email protected] 

Victor, Jennifer Nicoll

I have a time series panel that has missing values.  I want to copy,
duplicate, replace, or otherwise fill-in values in one variable with
other values in that variable.

For example, suppose I have variables time, state, district,
blackpopdist (black population in that district) and blackpopstate
(black population in that state.  My unit of analysis is district, so
states are listed as district=0.  I have blackpopdist for each
district>0, but missing for district==0.  I have blackpopstate for each
district==0, but missing otherwise.  I want to ultimately delete the
observations where district =0. Before I do so, I want my blackpopstate
variable to take on constant values for that state, for how ever many
districts are in it.  Therefore, for each year-state, I want to
duplicate the first value in blackpopstate to fillin the other missing
value for the rest of the districts in that year-state.  Then drop the
district=0 observation.

A sample starting dataset:
Time	state	dist	blackpopdist	blackpopstate
92	AL	0	.		1234
92	AL	1	234		.
92	AL	2	456		.
92	CA	0	.		4567
92	CA	1	2345		.
92	CA	2	12		.
93	AL	0	.		1235
93	AL 	1	235		.

A sample complete dataset:
Time	state	dist	blackpopdist	blackpopstate
92	AL	1	234		1234
92	AL	2	456		1234
92	CA	1	2345		4567
92	CA	2	12		4567
93	AL 	1	235		1235


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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