Statalist


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

st: AW: AW: Expanding observations and duplicating some values


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: AW: Expanding observations and duplicating some values
Date   Wed, 25 Mar 2009 14:40:58 +0100

<> 

BTW, as Thomas just said, I added missing days for the first "Unit" in my
-input- command, without mentioning it. Otherwise -fillin- cannot do its job
properly...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Martin Weiss
Gesendet: Mittwoch, 25. März 2009 14:31
An: [email protected]
Betreff: st: AW: Expanding observations and duplicating some values


<> 

I can see how -fillin- could do at least some of what you want...

*************
clear*

inp Unit Day NumberofEvents
1 3 4
1 5 1
1 2 0 
1 4 0
1 1 0
2 1 1
3 3 2
3 4 1
end

fillin Unit Day
drop _fillin

bys Unit (Day): gen cumul=sum(Number)

l, noo sepby(Unit)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Hannah Goble
Gesendet: Mittwoch, 25. März 2009 14:17
An: [email protected]
Betreff: st: Expanding observations and duplicating some values

Everyone,

I have a relatively large data set of multiple units observed over a  
length of days.  On each day, an event may occur or not; an event may  
occur more than once per day.  Currently, on days in which no events  
occur in a unit, there is no observation for that unit on that day,  
but I'd like to have an observation for each unit on each day of the  
observation period.  In other words, the data currently look something  
like this,


Unit		Day		Number of Events	Cumulative Events
1		3			4
4
1		5			1
5
2		1			1
1
3		3			2
2
3		4			1
3


and I'd like them to look like this,


Unit 	Day		Number of Events	Cumulative Events
1		1			0
0
1		2			0
0
1		3			4
4
1		4			0
4
1		5			1
5
2		1			1
1


Each unit is missing a different number of observations, and, although  
some of variables for the observations to be added will be zero, the  
cumulative count variables need to take their values from the most  
recent day on which an event occurred.  Does anyone have advice on  
expanding these observations and getting Stata to pull some values  
from existing observations?

Thank you for your time,
Hannah


Hannah Goble
Ph.D. Candidate
Department of Political Science
University of Wisconsin - Madison
110 North Hall
1050 Bascom Mall
Madison, WI 53706
[email protected]



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


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