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

# st: RE: RE: Programming Question

 From "Nick Cox" To Subject st: RE: RE: Programming Question Date Thu, 27 Nov 2003 12:20:09 -0000

```This code

replace Y = 0 if "`T'" == "" & id == `i' & Month == `m'
replace Y = 1 if "`T'" == "CAB" & id == `i' & Month == `m'
replace Y = 2 if "`T'" == "OXY" & id == `i' & Month == `m'
replace Y = 3 if "`T'" == "OTH" & id == `i' & Month == `m'
replace Y = 4 if "`T'" == "CAB OXY" & id == `i' & Month == `m'
replace Y = 5 if "`T'" == "CAB OTH" & id == `i' & Month == `m'
replace Y = 6 if "`T'" == "OTH OXY" & id == `i' & Month == `m'
replace Y = 7 if "`T'" == "CAB OTH OXY" & id == `i' & Month == `m'

would be better as

if "`T'" == "" replace Y = 0  if id == `i' & Month == `m'
else if if "`T'" == "CAB" replace Y = 1 if id == `i' & Month == `m'
...
else if "`T'" == "CAB OTH OXY" replace Y = 7 if id == `i' & Month ==
`m'

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

*
*   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–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index