Statalist


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

st: copy values


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

Hello Stata users:

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

Thank you, in advance, for your help!
___________________________________________
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



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