*! version 1.0.0 20may2018
help num2base26

Title

num2base26 -- A Stata interface to Mata's hidden numtobase26() function.

Description

num2base26 -- Converts an integer number into a letter and returns it.
It accepts as argument integer numbers like 1, 2,..., but also real valued numbers like 1.5, 4.534 or a macro containing the number
or any valid mathematical expression as long as it results in a number. Any number is rounded down to the nearest integer number.
This command was inspired by this post.
The command is similar to but not related to the Excelcol package (available from the SSC archive):
type ssc describe excelcol

Syntax

num2base26 number , [lower display Return(string)]

Options

lower return a lowercase letter. Default is uppercase letter.

display displays the letter.

Return(string) changes the name of the local macro that contains the returned letter. The default value is letter.
This option is more meant for my personal use,
because the name of the returning local macro was a different one before. I changed the name to make it easier to remember, but thereby broke
older do-files that rely heavily on the command.

Examples

. num2base26 4
. display "`r(letter)'"
"D"

. local num = 4
. num2base 4+`num', lower
. display "`r(letter)'"
"h"

Saved results

num2base26 saves the following in r():
Macro

r(letter) Letter

Author

Sven-Kristjan Bormann

Bug Reporting

Please submit bugs, comments and suggestions via email to: sven-kristjan@gmx.de