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