What I suggest is certainly not elegant yet it is simple and should work, too:
capture replace `v'=.
capture replace `v'=""
Sebastian
On Mon, 7 Mar 2005 17:50:02 -0000, Nick Cox <[email protected]> wrote:
> It would seem that there is no generic
> object or function to do what you want.
>
> As you know, -missing()- returns true
> or false to "is this missing?".
>
> But your code could presumably be
> condensed to
>
> local typ: type `v'
> local missvalue = cond(substr("`typ'", 1, 3) == "str", `""""', ".")
> replace `v' = `missvalue'
>
> and even to
>
> local missvalue = cond(substr("`: type `v''", 1, 3) == "str", `""""', ".")
> replace `v' = `missvalue'
>
> without, however, being quite as elegant
> as one might wish.
>
> Nick
> [email protected]
>
> David Kantor
>
> > If you are interested, I have used similar code in a slightly
> > different
> > way, which enables either -replace- or -post- (or both):
> >
> > local typ: type `v'
> > if substr("`typ'", 1, 3) == "str" {
> > local missvalue = `""""'
> > }
> > else {
> > local missvalue = "."
> > }
> >
> > ...
> > replace `v' = `missvalue'
> >
> > or:
> >
> > postfile postname `typ' var1 ...
> > ...
> > post postname (`missvalue') ...
> >
>
> *
> * 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/
>
--
- Seb F Buechte
-
- Stay tuned!
*
* 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/