08-10-2017 02:03 PM
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..
08-10-2017 02:07 PM
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.
08-10-2017 02:16 PM
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.
08-10-2017 03:31 PM
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.
08-10-2017 11:26 PM
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;