<?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: Separate Apt information from Street information in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363195#M85942</link>
    <description>&lt;P&gt;Always good to experiment and learn, but here are some things to be wary of.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Functions take some time to run.&amp;nbsp; It's faster to use INDEX once per DATA step instead of twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If "Apt" does not appear, INDEX will return 0.&amp;nbsp; Will the program still work in that case?&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2017 19:42:05 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-05-31T19:42:05Z</dc:date>
    <item>
      <title>Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363139#M85911</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Got a question about separating Apt information from address. The data looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Address&lt;/P&gt;&lt;P&gt;5213 Elmcrofa Blvd Apt 10210&lt;/P&gt;&lt;P&gt;5648 Sunset Blvd Apt 52103&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;I was thinking about using scan function, but not sure if the delimiter can be a character and how. The desired output would be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Address &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Apt&lt;/P&gt;&lt;P&gt;5213 Elmcrofa Blvd &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Apt 10210&lt;/P&gt;&lt;P&gt;5648 Sunset Blvd &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Apt 52103&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Fan&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 16:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363139#M85911</guid>
      <dc:creator>fannavivian</dc:creator>
      <dc:date>2017-05-31T16:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363144#M85914</link>
      <description>Street addresses are often more or less free text fields, which make them hard to parse by simple rules.&lt;BR /&gt;There have been several discussions on the forum regarding this, feel free to search and explore the hidden treasures of SAS Communities!</description>
      <pubDate>Wed, 31 May 2017 16:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363144#M85914</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-05-31T16:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363161#M85924</link>
      <description>&lt;P&gt;If you can rely on "Apt" indicating where to separate the text, this would work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;start = index(address, 'Apt');&lt;/P&gt;
&lt;P&gt;if start = 1 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; apartment = address;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; address = ' ';&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;else if start &amp;gt; 1 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; apartment = substr(address, start);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; address = substr(address, 1, start-1);&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have to consider other separators, such as 'apt' or 'APT' or 'apmnt', it becomes more detailed but can use pretty much the same tools.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 17:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363161#M85924</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-31T17:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363192#M85941</link>
      <description>&lt;P&gt;Thank you~~ This is similar to what I thought, but yours is more detailed. Just to share what I figured out a moment ago.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;address=substr(ADDRESS1, 1, index(ADDRESS1, 'Apt') - 1);&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363192#M85941</guid>
      <dc:creator>fannavivian</dc:creator>
      <dc:date>2017-05-31T19:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363195#M85942</link>
      <description>&lt;P&gt;Always good to experiment and learn, but here are some things to be wary of.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Functions take some time to run.&amp;nbsp; It's faster to use INDEX once per DATA step instead of twice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If "Apt" does not appear, INDEX will return 0.&amp;nbsp; Will the program still work in that case?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 19:42:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363195#M85942</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-31T19:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363203#M85945</link>
      <description>&lt;P&gt;Thanks. I'm not worry about the case you just mentioned, because the first left letter of address is always a number in my db. But I do have a question that what if there're other delimitors, such as "suite", "#", "STE", so what's your recommendation?&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 20:03:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363203#M85945</guid>
      <dc:creator>fannavivian</dc:creator>
      <dc:date>2017-05-31T20:03:31Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363206#M85946</link>
      <description>&lt;P&gt;Using the code I posted originally, an easy change would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;start = max(&amp;nbsp;index(address, 'Apt'), index(address, '#'), index(address, 'STE'), index(address, 'suite')&amp;nbsp;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you find other possible separators, it's easy enough to add to the list.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 20:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363206#M85946</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-31T20:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363210#M85947</link>
      <description>&lt;P&gt;Awesome!!!!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 20:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363210#M85947</guid>
      <dc:creator>fannavivian</dc:creator>
      <dc:date>2017-05-31T20:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363217#M85951</link>
      <description>&lt;P&gt;Index may not be the function to use. Index may find the Apt in "CAptain Jones St". You may want to look at INDEXW&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 20:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363217#M85951</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-31T20:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Separate Apt information from Street information</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363223#M85955</link>
      <description>&lt;P&gt;Good add up!&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 20:53:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separate-Apt-information-from-Street-information/m-p/363223#M85955</guid>
      <dc:creator>fannavivian</dc:creator>
      <dc:date>2017-05-31T20:53:36Z</dc:date>
    </item>
  </channel>
</rss>

