Statalist The Stata Listserver


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

st: RE: filling in gaps in data


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: filling in gaps in data
Date   Thu, 14 Sep 2006 18:51:58 +0100

It sounds as if "0" really means missing here. 

If so, the FAQ at http://www.stata.com/support/faqs/data/missing.html
applies with one straightforward change. 

replace CI_EV = CI_EV[_n-1] if CI_EV == 0 

Note that this would replace your first value with missing, 
and if your data are subsetted you should do this under -by:-. 

Thus I see no loops here. 

Apologies for previous null replies. 

Nick 
[email protected] 

Mr David L. Winter, HNC

I have the following data (FYI the values CI_EV and CI_RI are the
cumulative incidence value from the 'ci' option in -stcompet-)


      +--------------------------------+
      | time(hr)     CI_EV       CI_RI |
      |--------------------------------|
   1. |      1           0   .00069396 |
   2. |      2   .00069396           0 |
   3. |      3           0   .00138793 |
   4. |      4           0   .00208189 |
   5. |      5           0   .00277585 |
      |--------------------------------|
   6. |      6   .00138793           0 |
   7. |      7           0   .00346981 |
   8. |      8           0   .00416378 |
   9. |      9           0   .00485774 |
  10. |     10           0    .0055517 |
      |--------------------------------|
  11. |     11           0   .00624566 |
  12. |     12           0   .00693963 |
  13. |     13           0   .00763359 |
  14. |     14   .00208189           0 |
  15. |     15           0   .00832755 |
      |--------------------------------|
  16. |     16           0           0 |
  17. |     17           0     .009022 |
  18. |     18           0   .00971645 |
  19. |     19           0           0 |
  20. |     20           0   .01041139 |
      |--------------------------------|
  21. |     21           0   .01110633 |
  22. |     22           0   .01180126 |
  23. |     23           0    .0124962 |


As cumulative incidence is a step function I may want to identify the
value for CI_EV at, say, time =5, so I want to fill in the gaps with the
previous known value (so in the above example, the values of CI_EV for
time = 3,4 and 5 would be recoded to 0.00069396).

Some sort of loop should be in order but I am having problems with the
'grey matter'.  All assistance would be gratefully received.


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