Hi Austin,
So -recast- does help the fields have the desired lengths on the txt
file. But it does not seem to be consistent, i.e, when I open up the txt
file, the fields aren't as long as I had recasted them as in Stata.
Also, when using -outfile- with -runtogether- option, the effects of
-recast- do not get implemented in the txt file. Blank fields are only
one character in length. However, -outsheet- with options -nonames- and
-noquotes- implements the -recast- if the delimiter "|" was appended to
the variables before hand, but not consistently as I mentioned above.
I think this is because of the way I appended the character "|" at the
end of each variable. I did the following to append "|" at the end of
every variable:
foreach var of varlist a-z{
replace `var' = `var' + "|"
}
Is that ok? What did you have in mind when you said append the variables
with a "|" at the end?
Also, I tried recasting the variables to the desired lengths and then
simply using -outsheet- with the -delimiter- option to have the
character "|" as the delimiter. But even in this case the -recast-
didn't seem to work. Please advise. Thanks,
-Prash.
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Austin
Nichols
Sent: Friday, January 09, 2009 2:51 PM
To: [email protected]
Subject: Re: st: Field Widths and Delimiters
Prashant Shukla <[email protected]>:
Make the 7-character string a 10-character string if that is how long
you want it to be; see -help recast-.
On Fri, Jan 9, 2009 at 3:42 PM, Prashant Shukla
<[email protected]> wrote:
> Thanks a bunch Austin.
>
> I took the second route you prescribed and most of the steps worked
> perfectly. The only issue outstanding is that when I use -outfile-
using
> the -runtogether- option to write the text file, a variable formatted
as
> %10s but having an element only 7 characters long occupies only 7
> spaces. I want it to occupy the allocated space of 10 and then have
the
> adjacent "|". To elaborate the issue furthermore, even though the
format
> of the variable is %10s in the variables window the type column shows
> "str7" for the variable. I guess I want the type to be "str10".
>
> Of course, there are many such variables, with varying allocated and
> outputted lengths, in the file. What am I doing wrong here? Can you
> please recommend a way to correct this issue? Thank you so much.
>
> -Prash.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/