There is a typo here in that the format %02.0f should
be in " ". And I would definitely leave the old variable
in place. Otherwise this solution is neater than mine.
Nick
[email protected]
Jeph Herrin
> If your example is strictly true (you have all
> uppercase letters, you want to map A->1,..., Z->26),
> then:
>
> forv i=1/26 {
> replace myvar =
> subinstr(myvar,char(`i'+64),string(`i',%02.0f),.)
> }
T.J. Volant
> > How
> > can I program so that it will encode each unique
> > letter into a unique number? Example:
> > I got hundreds of combinations of strings like:
> > ABC
> > ABB
> > ACA
> > Then, encode only gives me 1,2,3 in order. But I would
> > like to label letter A=01, B=02, C=01 etc, and then
> > have encode give me 010203, etc. How can I program
> > this?
*
* 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/