[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: RE: RE: inputting string variables in comma-separated files
I don't know why you say that about -tostring-.
Consider the results of
. sysuse auto
. tostring mpg, format("%05.0f") replace
. l mpg
I regard this as a straightforward solution.
There are others, but my suggestion stands.
> 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.
> > 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.
> > >
> > > 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.
> > >
* For searches and help try: