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

RE: st: How to cope with string when transfrom from Epidata to Stata


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: How to cope with string when transfrom from Epidata to Stata
Date   Thu, 13 Oct 2005 14:58:56 +0100

What is wrong is that you are asking -destring- 
to do something that 

1. it was not designed to do 

and (more importantly) 

2. it finds impossible to do. 

-destring- needs to find _numeric_ content
in a variable and to be told to ignore 
all the non-numeric content; otherwise 
it can do nothing. Moreover, you may have 
some preference that "N" means 0 or 1 or
some other value, but nowhere did you 
tell Stata this. 

No matter, it is likely that 
-encode- will work for you. 

Nick 
n.j.cox@durham.ac.uk 

Jia Xiangping
> 
> Additionally, when I run -
> . destring v1, generate(vv1) float
> 
> I  was informed that
> v1 contains non-numeric characters; no generate
> 
> What's wrong?

> > When data were input from questionnaires, epidata (version3.1) was
> > used. One question, as "Did you applied credit last year", 
> was set as
> > "Boolean (yes/no)" in Epidata. But when data was exported to Stata
> > 8.2, the result is very frustrating:
> >
> > -des v1, detail-
> >
> >                        storage   display     value
> > variable name    type       format      label      variable label
> > 
> --------------------------------------------------------------
> -----------------
> > v1                      str1           %1s                 
> 1) did you
> > apply for a credit
> >                                                             
>            in 2004
> >
> > -sum v1, detail-
> >
> >            1) did you apply for a credit in 2004
> > -------------------------------------------------------------
> > no observations
> >
> > -list v1-
> >
> >  +----+
> >     | v1 |
> >     |----|
> >  1. |  N |
> >  2. |  N |
> >  3. |  N |
> >  4. |  N |
> >  5. |  N |
> >     |----|
> >  6. |  N |
> >  7. |  N |
> >  8. |  N |
> >  9. |  N |
> >  10. |  N |
> >     |----|
> >  11. |  N |
> >  12. |  N |
> >  13. |  N |
> >  14. |  N |
> >  15. |  N
> >
> > What I need is just a binary variable. Must I have to 
> transform it to
> > numerical variable firstly and then label variables and values again
> > manually? Are there any other ways I can apply?
> >
> > If I could foresee this problem, I would have defined variable v1 as
> > just numerical type in Epidata instead of "Boolean".

*
*   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