Hi,
I'm trying to convert ISO-alpha-2 codes to GLC-codes in order to use the gmap procedure:
data maps;
set maps;
GLC=put(BOOK_COUNTERPARTYCOUNTRY,$glcan.);
However, I get an error that the format glcan. was not found. Any idea what could be the cause?
Thanks,
KS
@fuhgidabowit wrote:
Hi,
Thanks for your quick responses. I found the solution. I forgot to specify the output statements to use the code:
options fmtsearch=(sashelp.mapfmts);
However, now I run into the next issue that the gmap procedure tells me that my ID variables are of different data types. Here is my code:
data maps;
set maps;
Country_Name=put(BOOK_COUNTERPARTYCOUNTRY,$isoa2lu.);
ID=put(Country_Name,$glcsun.);
run;
proc gmap data=maps map=maps.world;
id id;
choro sum_ctry;
run;
my ID-variable is alphanumeric. What's the matter?
Thanks,
KS
Proc contents results for maps.world:
Alphabetic List of Variables and Attributes # Variable Type Len Label 1 CONT Num 5 Numeric rep. for Continent 4 DENSITY Num 5 Levels for Reducing 2 ID Num 5 GLC: Country ID Number 7 LAT Num 8 Unprojected Latitude in Radians 8 LONG Num 8 Unprojected Longitude in Radians 3 SEGMENT Num 5 Country Segment Number 5 X Num 8 Projected Longitude: Cylindri 6 Y Num 8 Projected Latitude: Cylindri
clearly shows that ID is numeric.
The PUT statement that creates ID in your MAPS data set creates a character variable. Hence the mismatch.
perhaps
data maps; set maps; Country_Name=put(BOOK_COUNTERPARTYCOUNTRY,$isoa2lu.); ID=input ( put(Country_Name,$glcsun. -L), 5.); run;
to create a numeric ID.
Before you run this code, format $glcan. must be defined in your SAS code. Or it must be in your format library.
Which type is variable BOOK_COUNTERPARTYCOUNTRY? If it is numeric, SAS will automatically look for a numeric format.
Hi,
Thanks for your quick responses. I found the solution. I forgot to specify the output statements to use the code:
options fmtsearch=(sashelp.mapfmts);
However, now I run into the next issue that the gmap procedure tells me that my ID variables are of different data types. Here is my code:
data maps;
set maps;
Country_Name=put(BOOK_COUNTERPARTYCOUNTRY,$isoa2lu.);
ID=put(Country_Name,$glcsun.);
run;
proc gmap data=maps map=maps.world;
id id;
choro sum_ctry;
run;
my ID-variable is alphanumeric. What's the matter?
Thanks,
KS
If Country_Name is alphanumeric, you want to use INPUT instead of PUT.
I get the error message only when I use the gmap procedure, so its related to the ID variable, I guess.
Show us the LOG, not just the error messages but also the code.
Please paste the log into the window that appears when you click on the {i} icon. Do not show us the log any other way.
@fuhgidabowit wrote:
Hi,
Thanks for your quick responses. I found the solution. I forgot to specify the output statements to use the code:
options fmtsearch=(sashelp.mapfmts);
However, now I run into the next issue that the gmap procedure tells me that my ID variables are of different data types. Here is my code:
data maps;
set maps;
Country_Name=put(BOOK_COUNTERPARTYCOUNTRY,$isoa2lu.);
ID=put(Country_Name,$glcsun.);
run;
proc gmap data=maps map=maps.world;
id id;
choro sum_ctry;
run;
my ID-variable is alphanumeric. What's the matter?
Thanks,
KS
Proc contents results for maps.world:
Alphabetic List of Variables and Attributes # Variable Type Len Label 1 CONT Num 5 Numeric rep. for Continent 4 DENSITY Num 5 Levels for Reducing 2 ID Num 5 GLC: Country ID Number 7 LAT Num 8 Unprojected Latitude in Radians 8 LONG Num 8 Unprojected Longitude in Radians 3 SEGMENT Num 5 Country Segment Number 5 X Num 8 Projected Longitude: Cylindri 6 Y Num 8 Projected Latitude: Cylindri
clearly shows that ID is numeric.
The PUT statement that creates ID in your MAPS data set creates a character variable. Hence the mismatch.
perhaps
data maps; set maps; Country_Name=put(BOOK_COUNTERPARTYCOUNTRY,$isoa2lu.); ID=input ( put(Country_Name,$glcsun. -L), 5.); run;
to create a numeric ID.
Thanks,
that seems to work. However there are few issues which I had to correct manually:
- the format of some countries like Bosnia,Russia or Taiwan for some reason is not converted from ALPHA2-Codes to GLC-Codes
- Hong-Kong does not exist in the SAS-Names list as an own country ?
Thanks,
KS
@fuhgidabowit wrote:
Thanks,
that seems to work. However there are few issues which I had to correct manually:
- the format of some countries like Bosnia,Russia or Taiwan for some reason is not converted from ALPHA2-Codes to GLC-Codes
- Hong-Kong does not exist in the SAS-Names list as an own country ?
Thanks,
KS
Check the data sets actual values and there are some "political" issues involved that you may need to address. The PRC claims that Taiwan is not a separate country but part of China so some folks take steps not to aggravate China, Or may have a different name used than Taiwan. Note that the SAS Maps.Names set has Taiwan in "Overseas Territories, Dependent Areas, Disputed Territories". Similarly Bosnia and Russia may be listed under other names dependent on source.
And the status of Hong Kong is also a tad ambiguous as to "country" status.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.