Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Selecting specific observations and replacing values of theirvariables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Selecting specific observations and replacing values of theirvariables
Date   Fri, 1 Nov 2002 13:23:57 -0000

Christopher Olola wrote [with HTML attachment: please
see FAQ and pay attention to a concurrent thread!!!]
>
> I seek your help ....I have data being entered by two
> different clerks (resulting in two datasets - pig1 and
> pig2).  Verification of the 2 files (program used), results
> in a text file being generated with discrepancy errors.
> Using stata (infile), after formatting the ASCII file, I
> get a *.dta with contents snippet as....
>
>           date       paxno           entry         var
>                val
>   1.   00/07/02       02054       pig1:        PCO2
>          01.6
>   2.   00/07/02       XXXXX       pig2:       PCO2
>         01.3
>   3.   00/07/02       02059       pig1:       TRANSFUSED
>        2
>   4.   00/07/02       XXXXX       pig2:      TRANSFUSED
>       1
>   5.   00/07/02       02067       pig1:       DTIME
>          1930
>   6.   00/07/02       XXXXX       pig2:      DTIME
>         1920
>   7.   00/07/02       02067       pig1:      HCTSOURCE           3
>   8.   00/07/02       XXXXX       pig2:     HCTSOURCE           1
>   9.   00/07/02       02068       pig1:      TEMP
>         37.5
>  10.   00/07/02       XXXXX       pig2:    TEMP
>       37.8
>  11.   00/07/02       02069       pig1:     WEIGHT
>      06.5
>  12.   00/07/02       XXXXX       pig2:    WEIGHT
>     06.8
>
> problem:
>
> 1. I wish to replace XXXXX in variable "paxno" with the
> preceding paxno's value (valid value).

. replace paxno = paxno[_n-1] if paxno == "XXXXX"

See How can I replace missing values with previous or
following nonmissing values?
http://www.stata.com/support/faqs/data/missing.html
for relevant background.

> 2. Each two consecutive records belong tdiscrepancy patient
> and varibale "val" indicates the discrepacy between the two
> entries made by two clerks.

What's the question here?


Nick
[email protected]

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