A quibble on the side:
As it happens I guess no British postcode
is longer than 8 characters, but in
general this is dangerous, with greater
and lesser dangers.
Forget postcodes, and consider the possible
consequences of stipulating -str8-.
If I say
gen str8 whatever = "abcdefghi"
Stata assumes I mean what I say
and that I trust it to do the best
it can.
The consequence will be "abcdefgh"
everywhere, and no warning message.
The greater danger is thus loss of data.
If I say
gen str8 whatever = "foo"
the consequence is "foo" everywhere
and some wasted storage. That may be
trivial to you, but it is still avoidable.
I guess Emma has been using Stata for
a while and started when you _had_ to
specify a string type in generating
a string variable. For a few versions
past, that has no longer been compulsory.
It is best, in fact, not to do it, as
Stata is smarter at computing than you
are.
If I say
gen something = "foo"
-something- will be born -str3-.
Nick
[email protected]
Maurizio Gibin
> Thank you Emma...
> Easy and it's working!
Emma.Slaymaker
> gen str8 newvar=subinstr(oldvar," ","",.)
>
> if oldvar is your current postcode variable and newvar is a new one.
Maurizio.Gibin
> I am trying to trim all the spaces in a code, in particular an english
> unit postcode
> but I still haven't found the correct way. I downloaded the ptseed
> strip function but seems is not working.
> Can anyone please help me? The database I am working on is quite
> huge...
*
* 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/