BookmarkSubscribeRSS Feed
hi32
Calcite | Level 5

Dear All , 

               

 I have column(Retailer_country) and its holding values (us,china,india,japan) now i want to identify the continent of each country 

 which it belongs to , And save it in  a new column.

 

.This is my first sas post , Can Any one help me how i can i do this..

 

 

 

 

4 REPLIES 4
novinosrin
Tourmaline | Level 20

Welcome to SAS forum. Typical example of a case where you would use Proc format aka user defined format and use a put function or format statement in a datastep to apply that format. 

Reeza
Super User

See if you have access to the SASMAPS library on your computer. One of the datasets in there will have the mapping of countries to continents and you can use that to do the lookup.

ballardw
Super User

If you have a MAPSGFK library installed the data set Maps.gfk.World_attr has country names and a numeric code 91 to 97 for continent.

SuryaKiran
Meteorite | Level 14

Hi,

 

MAPSGFK is a Library in SAS that comes with the SAS product installation(Most cases). In this Library you can find WORLD_ATTR tabel where you can find most of the well known countries with continent code. Here is my sample code( make sure the values are case-sensitive so the contries names has to be all upcase)

data country;
infile datalines;
input country $15.;
datalines;
INDIA
CHINA
UNITED STATES
JAPAN
;
RUN;
/* 91-North America, 92-South America, 93-Europe, 94-Africa, 95-Asia, 96-South Pacific. */
PROC FORMAT ;
VALUE Cont  91="North America"
            92="South America"
												93="Europe"
												94="Africa"
												95="Asia"
												96="South Pacific";
RUN;

PROC SQL;
   CREATE TABLE WORK.QUERY_FOR_COUNTRY AS 
   SELECT t1.country, 
          t2.CONT format=cont.
      FROM WORK.COUNTRY t1
           INNER JOIN MAPSGFK.WORLD_ATTR t2 ON (t1.country = t2.ISONAME);
QUIT;

Thanks,

Suryakiran

Thanks,
Suryakiran

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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