Statalist The Stata Listserver


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

st: Replacing missing with valid values


From   "Carter Rees" <[email protected]>
To   <[email protected]>
Subject   st: Replacing missing with valid values
Date   Tue, 5 Jun 2007 10:50:35 -0400

Statalist,

I am working in Windows using Stata 9SE.

My data consists of 10 friendship nominations 5 male and 5 female.  I have a
handful of variables that are averages across all friends and I have broken
out the values of specific friends which make up the averages.  When this is
done I suffer from a missing data problem because some of the friends
nominated did not fill out the same survey as the respondent or couldn't be
identified.  So, I would like to create a "best friend" variable based upon
the first friend who has valid data on specific questions.  

The friendship nominations are ranked within gender so the first male friend
is the friend the respondent feels is their best male friend.  The same can
be done for females and it is possible to have both a male and female occupy
the same ranking simultaneously given they are ranked within gender.  In the
case that the respondent named a male and female friend who occupy the same
rank; I would like to make the best friend value equal to the average of the
two. 

My data is as follows mf (male friend) ff (female friend) with newvar being
the newly created generic best friend variable.  For brevity, I haven't
included the average values for each male/female combination.  

id 	mf1	mf2	mf3	mf4	mf5	ff1	ff2	ff3	ff4
ff5	newvar
1	.	.	3	1	4	.	.	.	.
.	  3	
2	2	4	3	4	5	5	2	1	1
2	  2
3	3	.	.	.	.	4	.	.	.
.	  3.5
4	.	1	1	3	3	1	4	3	3
1	  1
5	.	.	.	.	4	.	.	.	.
2	  3
6	5	2	4	.	.	1	.	.	.
.	  3

The value of the created variable for id 1 would be equal to that of mf3
(3).  Id = 2 would be equal to the average of mf1 and ff1 (2).  I am fairly
confident that I this is something I can program myself using a combination
of -replace- and if statements.  

The last step that I would like to take is to somehow determine what friend
(or average between valid male and female friends) my generic variable
newvar finally settled on.  This strikes me as asking Stata to remember the
final step it took in each case.  For example, I would like to have an
indicator variable which tells me that case 3 was set equal to the average
of mf1 and ff1.  I have thought about creating dummy variables and setting
their values equal to 1 if newvar was equal to say the value of mf1 etc.
However, this runs into the issue of the newvar value being able to be equal
to several of the friend values simultaneously.

Much appreciated,

Carter

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