Dear Ibarra
I am not proposing a very elegant way of doing it, but it might work
for you for the time being. Probably you are using the following
command for importing your data
insheet using mydata.txt
Hopefully you can open your dataset in some text editor (as you say it
is saved in txt format). Now before using the above command in Stata
open the data file in a text editor just before the first value of
us_id type an "a". So your text data should look like
us_id firm
a000007 x
010234 y
321098 z
112411 w
save the file and exit the text editor. Open Stata. Use the command
-insheet- as you were using earlier. Then replace the first us_id
value with
replace us_id="000007" in 1
compress
Hopefully it will do.
But I am telling you frankly more experienced Stata users may give you
a better and more elegant way of doing it.
Regards
Krishanu
On Feb 9, 2008 1:16 AM, Ms. Marilyn Ibarra <[email protected]> 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/
>
--
Read it: http://www.stata.com/support/faqs/res/statalist.html
Specially Question 3.
*
* 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/