On Thu, 29 Nov 2018, Stefano wrote:
nice idea, Allin! I was thinking that since numeric codes may prove
easier to
handle in some circumnstances, if it wasn't much trouble the numeric field
3166-1 could also be included (although I checked and apparently that is also
flawed, Wurzistan is missing).
Good point, we might as well include the numeric codes too. That
extension is now in git (not yet snapshots). Some illustrations of
what can be done:
<gretl>
? matrix matcodes = {248,112,004,040,422,798}
Generated matrix matcodes
? strings S = isocountry(matcodes, 1)
? print S
Array of strings, length 6
[1] "Ã…land Islands"
[2] "Belarus"
[3] "Afghanistan"
[4] "Austria"
[5] "Lebanon"
[6] "Tuvalu"
? nulldata 6 --preserve
periodicity: 1, maxobs: 6
observations range: 1 to 6
? series numcodes = matcodes'
Generated series numcodes (ID 2)
? strings S = isocountry(numcodes, 2)
? print S
Array of strings, length 6
[1] "AX"
[2] "BY"
[3] "AF"
[4] "AT"
[5] "LB"
[6] "TV"
? string numcode = isocountry("DE", 4)
Generated string numcode
? eval atof(numcode)
276
</gretl>
Note that if you specify output = 4 (numeric code) you actually get
the result in string form, but it's easily converted via atof().
Also, re. Wurzistan, on a match failure you get an empty string and a
warning is printed.
Allin