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-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1003 views
  • 1 like
  • 4 in conversation