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

st: transform string to numeric vars


From   Harald Seider <harald.seider@wiwi.uni-augsburg.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: transform string to numeric vars
Date   Tue, 03 Jun 2003 19:51:45 +0200

Dear List,

I came across a weird problem with STATAs destring command (I am using Stata8 on a XP environment).

My intention was to transfer a string variable "hospid" into a numeric variable (regardless the usefulness of such an action).
So far I understand there are two ways to proceed: real(var) and destring var. I would have expected that both commands will give identical results.
Unfortunately they don't.

So I compared both commands:

'generate hospidold = real(hospid)' and
'destring hospid, generate(hospidnew)'

When comparing hospidold and hospidnew I get slightly different results.

Example:

variables: hospid(string) hospidold(float) hospidnew(long)
content: 106010735 106010736 106010735

Therefore 'generate hospidold = real(hospid)' gives wrong results.

Has anybody faced this problem before? Is it a well non issue (I haven't found anything on the list so far).

Best
Harald Seider



************************************************
Dipl. oec. Harald Seider
Department of Economics II
Universitätsstraße 16
D-86159 Augsburg

Tel: +49-821-598 4208
Fax: +49-821-598 4232

E-Mail: harald.seider@wiwi.uni-augsburg.de



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