Home  /  Resources & support  /  FAQs  /  Real function returns missing values
Note: This FAQ applies to older versions of Stata; in particular, Stata 4.0 and earlier. It does not apply to the current version.

Why does the real function sometimes return missing values?

Title   Real function returns missing values
Author Stata technical support

The real function will return a missing value if any character in the string that it is converting from is not part of the number character set. This includes blanks! In fact, the most common cause of the real function returning missing values, is that the strings that you are converting contain leading or trailing blanks. You delete these blanks from consideration using the trim function.
        . gen nval = real(trim(sval))