I am not aware of a built-in. User-written functions
are beyond my capabilities, but the following ado
is a zeroth stab. Not tested much at all.
program ascii, rclass
version 8.2
local l = length(`"`0'"')
if `l' == 0 {
di as err "nothing to do"
exit 498
}
forval i = 1/`l' {
local c = substr(`"`0'"',`i',1)
if `"`c'"' != " " {
local found 0
forval j = 32/255 {
if `"`c'"' == char(`j') {
di as txt "`c'" as res %6.0f `j'
local ascii "`ascii'`j' "
local found 1
continue, break
}
}
if !`found' {
di as txt "`c' not known"
local ascii "`ascii'? "
}
}
}
return local ascii "`ascii'"
end
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of
> Andrew Felton
> Sent: 10 March 2005 20:20
> To: [email protected]
> Subject: st: Converting char to ascii
>
>
> Hi,
>
> Is there an inverse of the char() function? So that I
> could get ascii("a") = 97? -findit ascii- and a web
> search didn't seem to turn up anything. Thank you,
>
> Andrew Felton
> *
> * 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/
>
*
* 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/