BookmarkSubscribeRSS Feed
sasmaverick
Obsidian | Level 7

I have the following code which replaces country codes from a country code dataset.

 

%macro replace(file,country);
data &file.;
if _n_=1 then do;
if 0 then set country_codes;
declare hash h1 (dataset:'country_codes');
rc=h1.definekey('iso_code');
rc=h1.definedata('country');
rc=h1.definedone();
end;
call missing (of _all_);
set &file.;
rc=h1.find(key:&country.);
drop rc ISO_Code;
if missing(Country) then Country=&country.;
Country=upcase(Country);
run;
%mend replace;
%replace(contacts_all,country);

 

The above code replaces all instances of 'BR' to Brazil but in the final output, one observation of BR still remains. What could be causing this? Thank you.

2 REPLIES 2
KachiM
Rhodochrosite | Level 12

It is difficult to visualize your probelm.. The answer will be quick if you make us to see your problem in terms of some input data set(even mock will do) and the desired output data set.

ballardw
Super User

I would check to see if that value of "BR" is actually " BR" with a not very noticeable leading space.

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 661 views
  • 0 likes
  • 3 in conversation