BookmarkSubscribeRSS Feed
kkk9
Calcite | Level 5

Is there an in-built SAS format to apply iso3166alphatwo for country codes?

 

If so, I would appreciate it if you could provide me an example code.

 

Thanks!

 

5 REPLIES 5
Tom
Super User Tom
Super User

You can try making one from mapsgfk.world_attr.

 

data format;
  fmtname='$ISO1366ALPHATWO';
  set mapsgfk.world_attr(keep=ISOALPHA2 isoname);
  where not missing(isoalpha2);
  rename ISOALPHA2=start isoname=label;
run;

proc format cntlin=format /* fmtlib */;
run;
kkk9
Calcite | Level 5

Thank you for the reply. I would appreciate it if could explain the code and where "mapsgfk.world_attr" is located.

Tom
Super User Tom
Super User

@kkk9 wrote:

Thank you for the reply. I would appreciate it if could explain the code and where "mapsgfk.world_attr" is located.


MAKSGFK libref is part of SAS install.  I am not sure if you have to have licensed SAS/Graph to have it.

 

The data step creates a dataset in the style needed for defining a format.  It creates the minimum required variables of FTMNAME, START and LABEL.  The PROC FORMAT step then creates the format as defined by the dataset.

 

If you do not have the dataset then just copy the code/name pairs off of the internet and make your own code to create the format.  either directly in PROC FORMAT syntax. Or by first making a dataset like my code did.

SASKiwi
PROC Star

The MAPSGFK data library is provided by SAS as part of the SAS/GRAPH product. It includes datasets for mapping most countries and includes the WORLD_ATTR dataset. It will be available to you automatically if you have SAS/GRAPH installed. Have you tried running @Tom 's program? 

Patrick
Opal | Level 21

To add to what @Tom and @SASKiwi already shared:

If you have SAS Graph licensed then there is also already a macro library with country formats available. Using Formats for Traditional Map Data Set Variables

 

Below code demonstrates how to get access to these formats.

options insert=(fmtsearch=sashelp.mapfmts);
data _null_;
  iso=364;
  put iso ison2a.;
run;

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 5 replies
  • 811 views
  • 1 like
  • 4 in conversation