<?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: Finding words wrapped with single/double quotes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824305#M325525</link>
    <description>&lt;P&gt;I guess this is a case for using regular expressions. Have a look at the code below. I am not regular expression expert and there might be easier ways of doing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  input
    text $char256.
  ;

  re1 = prxparse('/([\s"|"\A][^"]*"\s)/');
  qt1 = prxmatch(re1, text);
  re2 = prxparse("/([\s'|'\A][^']*'\s)/");
  qt2 = prxmatch(re2, text);

  if qt1 then do;
    value = prxposn(re1, 1, text);
  end;

  if qt2 then do;
    value = prxposn(re2, 1, text);
  end;

  value2 = dequote(value);
  cards;
"Tech Data1"
'Tech Data2' Company
abc "Tech Data" Company
def 'WOW' Company
John's &amp;amp; Gary's world
abc
123 "O'Reilly" here
456 'O"Reilly' here
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2022 09:11:29 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2022-07-20T09:11:29Z</dc:date>
    <item>
      <title>Finding words wrapped with single/double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824173#M325452</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to find the records that have words wrapped with single/double quotes. For example, "Tech Data" Company, "WOW" Company etc. But my code shouldn't count the record like this - John's &amp;amp; Gary's world.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 15:31:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824173#M325452</guid>
      <dc:creator>gandikk</dc:creator>
      <dc:date>2022-07-19T15:31:29Z</dc:date>
    </item>
    <item>
      <title>Re: Finding words wrapped with single/double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824192#M325456</link>
      <description>&lt;P&gt;Think very carefully and provide a &lt;STRONG&gt;rule&lt;/STRONG&gt; that describes exactly why the second record is not counted. An example is not a rule that can be programmed.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 16:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824192#M325456</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-19T16:24:45Z</dc:date>
    </item>
    <item>
      <title>Re: Finding words wrapped with single/double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824196#M325458</link>
      <description>&lt;P&gt;Thanks for your reply!! I didn't get the rule from customer. I got examples only. I believe that the customer doesn't want to consider a single quote if it is an&amp;nbsp;apostrophe. So, in the 2nd example, though there are 2 single quotes, both are&amp;nbsp;apostrophes. My rule is that if a single with 's' as an immediate character, we shouldn't count it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 16:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824196#M325458</guid>
      <dc:creator>gandikk</dc:creator>
      <dc:date>2022-07-19T16:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: Finding words wrapped with single/double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824247#M325494</link>
      <description>&lt;P&gt;Problem with examples.&lt;/P&gt;
&lt;P&gt;What if you have measurements in feet and inches?&amp;nbsp; 5' 6"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Angular measurements, such as latitude and longitude where the ' and " can be used for minutes and seconds (fractions of a degree)?&lt;/P&gt;
&lt;P&gt;Contractions:&amp;nbsp; Don't&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might be considering exclusion when there are any 2 characters on either side of the ' (more common) or ". But the hanging possessives like Jones' are a headache.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There might be some slick approaches with Regular expressions but I'm frankly too lazy at the moment to tackle a potentially very obnoxious set of search and refine search codes for such.&lt;/P&gt;
&lt;P&gt;I spent some time a long time ago dealing with cleaning up text with measurements such as 2" by 36" in the middle of other text and remember it was a headache to differentiate from the other quoted text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 21:46:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824247#M325494</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-19T21:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Finding words wrapped with single/double quotes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824305#M325525</link>
      <description>&lt;P&gt;I guess this is a case for using regular expressions. Have a look at the code below. I am not regular expression expert and there might be easier ways of doing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards truncover;
  input
    text $char256.
  ;

  re1 = prxparse('/([\s"|"\A][^"]*"\s)/');
  qt1 = prxmatch(re1, text);
  re2 = prxparse("/([\s'|'\A][^']*'\s)/");
  qt2 = prxmatch(re2, text);

  if qt1 then do;
    value = prxposn(re1, 1, text);
  end;

  if qt2 then do;
    value = prxposn(re2, 1, text);
  end;

  value2 = dequote(value);
  cards;
"Tech Data1"
'Tech Data2' Company
abc "Tech Data" Company
def 'WOW' Company
John's &amp;amp; Gary's world
abc
123 "O'Reilly" here
456 'O"Reilly' here
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2022 09:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Finding-words-wrapped-with-single-double-quotes/m-p/824305#M325525</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2022-07-20T09:11:29Z</dc:date>
    </item>
  </channel>
</rss>

