<?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: Data Parsing - How to extract specific words from a sentence by rules in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955470#M373151</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    location = find(data,'BPS.STQR');
    if location&amp;gt;0 then x2=scan(substr(data,location+9),1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 08 Jan 2025 12:40:11 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-01-08T12:40:11Z</dc:date>
    <item>
      <title>Data Parsing - How to extract specific words from a sentence by rules</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955458#M373145</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Please find below data Have and&amp;nbsp; data Want.&lt;/P&gt;
&lt;P&gt;We would like to extract X1 from the data according to the following rules:&lt;/P&gt;
&lt;P&gt;1. it appears after the last back slash in the sentence&lt;/P&gt;
&lt;P&gt;2. and also before the first dot following this word (if there is a dot)&lt;/P&gt;
&lt;P&gt;3. and this word contains only capital letters or under score in it (without small letters)&lt;/P&gt;
&lt;P&gt;4. and there is no garbage after this word (such as '..')&lt;/P&gt;
&lt;P&gt;5. if it can not find a word that follows all theses rules than write NOWORD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We would like to extract X2 from the data according to the following rules:&lt;/P&gt;
&lt;P&gt;1. it appears always after this word&amp;nbsp;BPS.STQR/ or this word&amp;nbsp;BPS.STQR,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in other words it appears after&amp;nbsp;BPS.STQR and is surrounded with '/' or with ','&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;----------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Data have ;&lt;BR /&gt;input data $60. ;&lt;BR /&gt;cards ;&lt;BR /&gt;data/dataflow/BPS.STQR/WAB/1.0/NER_PGTABC&lt;BR /&gt;data/dataflow/wow/BPS.STQR,WAB,1.0/NER_QZW&lt;BR /&gt;data/dataflow/wow/BPS.STQR,WAB,1.0/NER_QZW ..&lt;BR /&gt;data/dataflow/wow/BPS.STQR,WAB,1.0/NER_QZW.ABCDEFG&lt;BR /&gt;/availability/dataflow/*/*/*/*/-&lt;BR /&gt;/availability&lt;/P&gt;
&lt;P&gt;;&lt;BR /&gt;Run ;&lt;/P&gt;
&lt;P&gt;Data Want ;&lt;BR /&gt;input x1 $10. x2 $7. ;&lt;BR /&gt;cards ;&lt;BR /&gt;NER_PGTABC WAB&lt;BR /&gt;NER_QZW WAB&lt;BR /&gt;NER_QZW WAB&lt;BR /&gt;NER_QZW WAB&lt;/P&gt;
&lt;P&gt;NOWORD&lt;/P&gt;
&lt;P&gt;NOWORD&lt;/P&gt;
&lt;P&gt;;&lt;BR /&gt;Run ;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 09:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955458#M373145</guid>
      <dc:creator>J111</dc:creator>
      <dc:date>2025-01-08T09:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: Data Parsing - How to extract specific words from a sentence by rules</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955466#M373150</link>
      <description>&lt;P&gt;Hellow,&lt;/P&gt;
&lt;P&gt;Seems I found a solution for calculating X1 - view data test:-&lt;/P&gt;
&lt;P&gt;Would appreciate your help regarding X2..&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Data&lt;STRONG&gt; test&lt;/STRONG&gt; ;&lt;BR /&gt;set have ;&lt;BR /&gt;X1 = scan(scan(data,-1,"/"),1,'.') ;&lt;BR /&gt;if count(x1,lowcase(X1)) = 1 then X1 = 'NOWORD' ; &lt;BR /&gt;Run ;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 11:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955466#M373150</guid>
      <dc:creator>J111</dc:creator>
      <dc:date>2025-01-08T11:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Data Parsing - How to extract specific words from a sentence by rules</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955470#M373151</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    location = find(data,'BPS.STQR');
    if location&amp;gt;0 then x2=scan(substr(data,location+9),1);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Jan 2025 12:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955470#M373151</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-08T12:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Data Parsing - How to extract specific words from a sentence by rules</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955471#M373152</link>
      <description>I'm curious why you find a match for X1 in the 3rd row of your input dataset - doesn't that break the rule of 'no garbage' like '..' after the word?  Or is garbage OK as long as there's a space preceding it?  Also, could you define garbage?  Any non A-Z or underscore?  It does seem like you might get a more robust solution using one of the PRX* functions.</description>
      <pubDate>Wed, 08 Jan 2025 13:04:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955471#M373152</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-01-08T13:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: Data Parsing - How to extract specific words from a sentence by rules</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955474#M373153</link>
      <description>&lt;P&gt;A little clarification&lt;/P&gt;
&lt;P&gt;The purpose is to clean the words from the garbage&lt;/P&gt;
&lt;P&gt;as long as they have upercase or underscores.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 13:57:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-Parsing-How-to-extract-specific-words-from-a-sentence-by/m-p/955474#M373153</guid>
      <dc:creator>J111</dc:creator>
      <dc:date>2025-01-08T13:57:27Z</dc:date>
    </item>
  </channel>
</rss>

