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

st: Setting a missing value in a generic context


From   David Kantor <[email protected]>
To   [email protected]
Subject   st: Setting a missing value in a generic context
Date   Fri, 04 Mar 2005 17:20:24 -0500

Hi everyone,

Is there a concise way to set a variable to a missing value if you don't know its type (string vs. numeric)? This would be the reverse of the mi() function -- reverse in that you are setting rather than testing the value.

Suppose I have a local v that contains a variable name, and I want to replace the variable to missing.

Is there a way to do it in one easy command? Presently, I have been doing something like...

local typ: type `v'
if substr("`typ'", 1, 3) == "str" {
replace `v' = ""
}
else {
replace `v' = .
}

(or other similar things involving macros). (And in another setting, I am -post-ing a missing value, rather than replacing it in a variable.)

What I'd like is something like
replace `v' = universal_missing_symbol_that_works_regardless_of_data_type

I don't suppose it exists, but please let me know if I've overlooked something.
If it doesn't exist, it's on my wish list.

-- David

David Kantor
Institute for Policy Studies
Johns Hopkins University
[email protected]
410-516-5404
*
* 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