<?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: How to extract particular text from character string? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160861#M263311</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your data are really that consistent then you might be able to use something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat street $100.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length city $30.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input street &amp;amp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; city=scan(substr(_infile_,length(street)+1,),1,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp; state=scan(_infile_,-2,' ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; zip=scan(_infile_,-1,' ');&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;4552 east 32nd street, apt 4&amp;nbsp; new york, ny&amp;nbsp; 12209-1234&lt;/P&gt;&lt;P&gt;23 nearby blvd.&amp;nbsp; pittsburgh, pa&amp;nbsp; 15217&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Feb 2015 15:42:31 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2015-02-10T15:42:31Z</dc:date>
    <item>
      <title>How to extract particular text from character string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160860#M263310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a character variable for address which I'd like to use to create new variables for just the full address's&lt;/P&gt;&lt;P&gt;- street address&lt;/P&gt;&lt;P&gt;-city&lt;/P&gt;&lt;P&gt;-state&lt;/P&gt;&lt;P&gt;-zip&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am doing this using the substring function (i.e. state=substr(addr,length(addr)-1,2); )&lt;/P&gt;&lt;P&gt;however, the data is always entered so there is only space between the street address and city instead of, say, a comma. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would anyone have suggestions for how I may go about creating the street address and city variables then?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The help is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 14:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160860#M263310</guid>
      <dc:creator>Maisha_Huq</dc:creator>
      <dc:date>2015-02-10T14:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular text from character string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160861#M263311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your data are really that consistent then you might be able to use something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat street $100.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length city $30.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input street &amp;amp;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; city=scan(substr(_infile_,length(street)+1,),1,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp; state=scan(_infile_,-2,' ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; zip=scan(_infile_,-1,' ');&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;4552 east 32nd street, apt 4&amp;nbsp; new york, ny&amp;nbsp; 12209-1234&lt;/P&gt;&lt;P&gt;23 nearby blvd.&amp;nbsp; pittsburgh, pa&amp;nbsp; 15217&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Feb 2015 15:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160861#M263311</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-10T15:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular text from character string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160862#M263312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A __default_attr="827571" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt;: Here is another thought. Depending upon the accuracy of your city names, you might be able to get around the various problems as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length address $150;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; address=_infile_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;4552 east 32nd street, apt 4 albany, ny 12209-1234&lt;/P&gt;&lt;P&gt;23 nearby blvd. pittsburgh, pa 15217&lt;/P&gt;&lt;P&gt;12345 west&amp;nbsp;&amp;nbsp; north street, apt 12 (3rd floor) Arlington Heights, IL 60004-6667&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename dummy temp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; file dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; put address;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want (drop=citystate);&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat street $100.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat citystate $50.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length city $30;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length state $3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat zip $10.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile dummy;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _infile_=compbl(translate(_infile_,' ','09'x));&lt;/P&gt;&lt;P&gt;&amp;nbsp; zip=scan(_infile_,-1,' ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; citystate=zipcity(substr(zip,1,5));&lt;/P&gt;&lt;P&gt;&amp;nbsp; city=scan(citystate,1,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp; state=scan(citystate,2,',');&lt;/P&gt;&lt;P&gt;&amp;nbsp; street=substr(_infile_,1,find(upcase(_infile_),strip(upcase(city)))-1);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 20:00:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160862#M263312</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2015-02-11T20:00:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular text from character string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160863#M263313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arthur,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try this!&amp;nbsp; Something I left out, though:&amp;nbsp; is there a way to extract a string (which we know is all uppercase) between two specific delimiters in SAS (i.e. my two delimiters are a double space and a comma)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 12:44:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160863#M263313</guid>
      <dc:creator>Maisha_Huq</dc:creator>
      <dc:date>2015-02-12T12:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract particular text from character string?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160864#M263314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For fixed format strings you may take some time to read up on perl regular expressions.&amp;nbsp; It could save you some time writing all the necessary if thens.&amp;nbsp; &lt;A href="http://www.cs.tut.fi/~jkorpela/perl/regexp.html"&gt;http://www.cs.tut.fi/~jkorpela/perl/regexp.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I fyou are still going to use string functions, then look at index().&amp;nbsp; So if I had:&lt;/P&gt;&lt;P&gt;001&amp;nbsp; ABC, 12&lt;/P&gt;&lt;P&gt;And I do substr(string,index(string,"&amp;nbsp; ")+2,index(string,",") - (index(string,"&amp;nbsp; ")+2));&lt;/P&gt;&lt;P&gt;This means start taking characters from where I find two spaces (+2 so I don't get the spaces) up to where I find the comma (less two for the original spaces).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 13:21:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-extract-particular-text-from-character-string/m-p/160864#M263314</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-02-12T13:21:00Z</dc:date>
    </item>
  </channel>
</rss>

