BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fuhgidabowit
Calcite | Level 5

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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.

 

View solution in original post

9 REPLIES 9
PaigeMiller
Diamond | Level 26

Before you run this code, format $glcan. must be defined in your SAS code. Or it must be in your format library.

 

--
Paige Miller
fuhgidabowit
Calcite | Level 5

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

PaigeMiller
Diamond | Level 26

If Country_Name is alphanumeric, you want to use INPUT instead of PUT.

--
Paige Miller
fuhgidabowit
Calcite | Level 5

I get the error message only when I use the gmap procedure, so its related to the ID variable, I guess.

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
ballardw
Super User

@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.

 

fuhgidabowit
Calcite | Level 5

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

ballardw
Super User

@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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 904 views
  • 0 likes
  • 4 in conversation