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

Re: st: RE: RE: inputting string variables in comma-separatedfiles


From   Adrian.P.Mander@gsk.com
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: RE: inputting string variables in comma-separatedfiles
Date   Wed, 19 May 2004 15:03:22 +0100

A simpler solution might be to add an extra cell in your excel column with
a letter in it...
Then STATA will know to read that column in as a string.. then just delete
the
extra cell.

cheers
Ade


Adrian Mander MSc PhD, Principal Statistician, GlaxoSmithKline, Mail Code
HW8133, New Frontiers Science Park (South), Harlow, Essex, CM19 5AW. Tel:
01279 63 1203 Fax: 01279 64 4677


                                                                                                                                               
                      "Rebecca Kalmus"                                                                                                         
                      <kalmus@fas.harvard.edu>                                                                                                 
                                                                                                                                               
                      Sent by:                         To:      statalist@hsphsun2.harvard.edu                                                 
                      owner-statalist@hsphsun2.                                                                                                
                      harvard.edu                      cc:                                                                                     
                                                       Subject: st: RE: RE: inputting string variables in comma-separated files                
                                                                                                                                               
                      19-May-2004 14:44                                                                                                        
                      Please respond to                                                                                                        
                      statalist@hsphsun2.harvar                                                                                                
                      d.edu                                                                                                                    
                                                                                                                                               
                                                                                                                                               



Once I've read the comma-separated file into Stata, Stata has already read
the variable as numeric.  The leading zeros are already gone, so
converting the variable to string using tostring doesn't help.

In the past I've gotten around this problem by converting the
comma-separated file to Stata format using Stat/transfer, with which I can
specify that the variable should be read as string.  However, it seems
like there should be a more straightforward solution.

Rebecca Kalmus

> >From   "Nick Cox" <n.j.cox@durham.ac.uk>
> To   <statalist@hsphsun2.harvard.edu>
> Subject   st: RE: inputting string variables in comma-separated files
> Date   Tue, 18 May 2004 19:46:19 +0100
>
>
--------------------------------------------------------------------------------

>
> A good bet in this circumstance is to make
> it a string variable again using -tostring-.
> Make sure you specify a format which produces
> leading zeros.
>
> Nick
> n.j.cox@durham.ac.uk
>
> > -----Original Message-----
> > From: owner-statalist@hsphsun2.harvard.edu
> > [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of
> > Rebecca Kalmus
> > Sent: 18 May 2004 19:36
> > To: statalist@hsphsun2.harvard.edu
> > Subject: st: inputting string variables in comma-separated files
> >
> >
> > Dear Stata users,
> >
> > When inputting a comma-separated file using infile or
> > insheet, how can I
> > force Stata to read a variable as string?  I have a variable
> > that Stata
> > automatically reads as numeric, but contains leading zeros
> > that are lost
> > when read as numberic.  I'd like to force Stata to read this
> > variable as
> > string instead.
> >
> > Thanks,
> >
> > Rebecca Kalmus
> > *
> > *   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/
> >
>
*
*   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/







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