<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loop and Return Value from Source List in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675574#M36665</link>
    <description>It's the last non-blank usually, it's just that it could be in any of the 5 fields depending on the length of the address</description>
    <pubDate>Mon, 10 Aug 2020 13:02:55 GMT</pubDate>
    <dc:creator>JSifontes</dc:creator>
    <dc:date>2020-08-10T13:02:55Z</dc:date>
    <item>
      <title>Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675270#M36652</link>
      <description>&lt;P&gt;Hey guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to figure out the best approach for this and what I need to do is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 data sets:&lt;/P&gt;&lt;P&gt;Set1: Countries&lt;/P&gt;&lt;P&gt;Country_Code, Country_Name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set2: Address FIle&lt;/P&gt;&lt;P&gt;Customer_Name, Address_1 through Address_5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The address file is free form text, and what I want to do is loop over the countries set and if it finds a matching country from the Country_Name column in Set1 within Address_1-5 of Set2&amp;nbsp; then return the Country_Code in a new Column on Set2&lt;/P&gt;&lt;P&gt;I just have no clue how to formulate that loop or what the best approach would be&lt;/P&gt;&lt;P&gt;All suggestions welcome!&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 18:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675270#M36652</guid>
      <dc:creator>JSifontes</dc:creator>
      <dc:date>2020-08-07T18:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675281#M36653</link>
      <description>&lt;P&gt;I think you want to strongly consider your requirements.&lt;/P&gt;
&lt;P&gt;The approach you suggest, besides being more than a tad awkward is entirely too likely to return false results because names of countries are known to appear in street addresses and city names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might help to provide an example of your two data sets though, and show what you expect to be the results of the process using them. SMALL examples as you have to provide the example output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 19:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675281#M36653</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-07T19:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675297#M36654</link>
      <description>&lt;P&gt;I agree completely with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;. Here's a quick mock-up that demonstrates the problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Codes;
	length CountryName $20 CountryCode 8;
	input CountryName &amp;amp; CountryCode;
	cards;
Brazil  1
Canada  2
Mexico  3
United States  4
run;

data Addresses;
	infile cards missover;
	length Name Address1 Address2 Address3 Address4 Address5 $20;
	input Name &amp;amp; Address1 &amp;amp; Address2 &amp;amp; Address3 &amp;amp; Address4 &amp;amp; Address5;
	cards;
Name 1  123 Some Street  Detroit, MI  United States
Name 2  RR 123  Out of the way county  Carleton  Ontario  Canada
Name 3  Problem address  456 Canada Lane  Florida  United States
Name 4  Another address  789 Some Street  Puerto Vallarta
Name 5  9876 Mexico Street  Washington County  Delaware
run;

data Addresses2;
	set Addresses;
	length ComboAddr $1000;
	ComboAddr = catx(" ", Address1, Address2, Address3, Address4, Address5);
run;

proc sql noprint;
	create table Addresses3 as
		select Name, ComboAddr, CountryName, CountryCode
			from Addresses2 a left outer join Codes c on(find(ComboAddr, CountryName, "it") &amp;gt; 1) order by Name;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 20:56:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675297#M36654</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2020-08-07T20:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675298#M36655</link>
      <description>&lt;P&gt;Agree with you both, valid points, the issue is that the address fields allow the users to input the country in any of the 5 fields, it all depends on the size of the address so the country could be in any of the 5 fields. I know it won't be super accurate in that regard when it has a country within the address as shown below, but I have to tackle the problem for the majority of cases I suppose 80/20 rule.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2020 21:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675298#M36655</guid>
      <dc:creator>JSifontes</dc:creator>
      <dc:date>2020-08-07T21:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675353#M36658</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/340758"&gt;@JSifontes&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Agree with you both, valid points, the issue is that &lt;EM&gt;&lt;STRONG&gt;the address fields allow the users to input the country in any of the 5 fields&lt;/STRONG&gt;&lt;/EM&gt;, it all depends on the size of the address so the country could be in any of the 5 fields.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is it really any of the 5 fields, or would country always be the last non-blank field?&amp;nbsp; And does every record have a country?&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2020 04:24:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675353#M36658</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-08T04:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675574#M36665</link>
      <description>It's the last non-blank usually, it's just that it could be in any of the 5 fields depending on the length of the address</description>
      <pubDate>Mon, 10 Aug 2020 13:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675574#M36665</guid>
      <dc:creator>JSifontes</dc:creator>
      <dc:date>2020-08-10T13:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675575#M36666</link>
      <description>And yes every record has a country</description>
      <pubDate>Mon, 10 Aug 2020 13:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675575#M36666</guid>
      <dc:creator>JSifontes</dc:creator>
      <dc:date>2020-08-10T13:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Loop and Return Value from Source List</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675599#M36668</link>
      <description>&lt;P&gt;If every record has a country, it gets a little easier. You can just set aside the entries with more than one apparent country for manual review.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Mon, 10 Aug 2020 14:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Loop-and-Return-Value-from-Source-List/m-p/675599#M36668</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2020-08-10T14:09:34Z</dc:date>
    </item>
  </channel>
</rss>

