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

Re: st: Help with destring

From   Ted Anagnoson <>
Subject   Re: st: Help with destring
Date   Tue, 10 Jul 2007 13:07:44 -0700

When I have numbers that are strings, I almost always have good luck with the "real" function, rather than encode/decode or destring, etc. If someone said this and I missed it, I apologize....

For version 9, it is in the D Manual, Data Management, under functions, p. 170.

Ted Anagnoson

At 02:31 AM 7/11/2007 +0900, Joseph Coveney wrote:

Donald Spady wrote:

I have data that are string data and want to convert them to numeric.  I
would expect destring to do this but it doesn't.  For example, here is a
 tab Worker_Type

worker  Freq. Percent Cum.

Administration 12 9.16 9.16
Allied 44 33.59 42.75
Attending 26 19.85 62.60
Clerk 9 6.87 69.47
Med Student 17 12.98 82.44
Resident/Fellow 23 17.56 100.00

Total 131 100.00

The values are all strings.
When I do
Destring worker, generate(nworker)
I get the message
destring worker, gen(nworker)
worker contains nonnumeric characters; no generate
r; t=0.02 10:31:13

It seems to me that if I want to convert a string, that implicitly means
there are nonnumeric characters.  What am I doing wrong?  I am using


Roughly stated, -destring- converts string numerals into numerical data.
It's not clear what you're expecting the numerical data version of worker
to be, but it seems as if you want something like -encode-.

Joseph Coveney

*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index