Statalist


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

st: RE: need help destringing a variable


From   "Steichen, Thomas J." <SteichT@rjrt.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: need help destringing a variable
Date   Fri, 14 Sep 2007 14:25:02 -0400

The following might work...

destring grade_school, generate(grade_num) ///
  ignore("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+-=~~{}[]|\:;<>,.?/") 

However, it will set missing things like "first", "second", etc and mess up things like "3-4" or "3/5".
You need to look carefully at what your entries are like.

-----------------------------------
Thomas J. Steichen
steicht@rjrt.com
-----------------------------------
 
-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Daniel Macneil
Sent: Friday, September 14, 2007 2:04 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: need help destringing a variable

hi,

this should be easy. I just want to convert all the strings in one variable into integers.

e.g., the variable is grade_school (current grade in school)and the variable column has "2nd" 
"5th" etc., and I want to make it "2", "5" by issuing just one command.

thanks
James






D. James MacNeil
Doctoral Candidate
Harvard Graduate School of Education
macneida@gse.harvard.edu
*
*   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/

-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any
attachment(s), contains information that may be confidential,
protected by the attorney-client or other legal privileges, and/or
proprietary non-public information. If you are not an intended
recipient of this message or an authorized assistant to an intended
recipient, please notify the sender by replying to this message and
then delete it from your system. Use, dissemination, distribution,
or reproduction of this message and/or any of its attachments (if
any) by unintended recipients is not authorized and may be
unlawful.   

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