Statalist


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

Re: st: importing txt file changes format of variable


From   Arun Rajamohan <arajamoh@uwo.ca>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: importing txt file changes format of variable
Date   Fri, 08 Feb 2008 15:11:34 -0500

I am not sure how huge your dataset is but if you can copy it and paste it into the data editor in stata and later splitting the variable (split var1) usually keeps all variables as string.

-A


On Feb 8, 2008, at 2:46 PM, Ms. Marilyn Ibarra wrote:


I have the following data in a txt file:

us_id       firm
000007       x
010234       y
321098       z
112411       w

When I import it into stata I get this:

us_id       firm
7            x
10234        y
321098       z
112411       w

Where the us_id changes in the first two observations (it changes for any observations that have a us_id with zeros at the beginning).  I need us_id to be a 6 digit id number for each firm (ncluding any zeros at the beginning).  This needs to be a string variable but is a numeric variable when imported into STATA.  

Have any idea on how to fix this problem?  

Thanks in advance,
Marilyn.

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



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Arun Rajamohan PhD
Department of Biology
Room 237, Biological & Geological Sciences Building
1151 Richmond Street North
The University of Western Ontario
London, ON N6A 5B7 CANADA
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





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