Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: Filling missing rank information


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Filling missing rank information
Date   Mon, 25 Oct 2010 16:00:06 +0100

I suspect that when you say "datasets" you mean "panels" or some equivalent. In Stata a dataset is whatever you might -save- in a .dta file. 

Alternatively, if you are indeed storing these data in multiple datasets, life is going to be much easier if you combine them into one with an identifier variable. 

That done, check out -fillin-. See the help and also 

SJ-5-1  dm0011  . . . . . . . . . . . . . .  Stata tip 17: Filling in the gaps
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q1/05   SJ 5(1):135--136                                 (no commands)
        tips for using fillin to fill in gaps in a rectangular
        data structure

Nick 
n.j.cox@durham.ac.uk 

Trelle Sven

I have several datasets with two variables: rank (integer) and prop
(numeric variable). All datasets should have 8 observations in the end
and ranks should range from 2 to 9. However, some datasets have less
than 8 observations due to missing information (the number of missing
ranks is different in the different datasets, however). I want to fill
in the missing rank variable with the missing ranks (and replace the
prop variable for these ranks with 0 which obviously isn't a problem). 
I started to program a very complicated way but are currently stuck and
can imagine that there is an easy way to do it ... (I can easiliy fill
in ranks if they are missing at the extremes but if ranks are missing in
the middle?).
Does anybody have an idea?

Below is an extract of possible datasets 

Thanks for any help in advance.
Sven

ex1
rank	prop
5	0.1
6	0.5
9	0.01

=> should be
rank	prop
2	0
3	0
4	0
5	0.1
6	0.5
7	0
8	0
9	0.01

ex2
rank	prop
2	0.006
3	0.03
4	0.005

ex3
rank	prop
2	0.006
3	0.03
4	0.005
5	0.1
6	0.5
9	0.01


*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index