<?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 find partial strings and count the total amount, then create a macro number? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/369042#M65017</link>
    <description>&lt;P&gt;What is it your actually trying to do? &amp;nbsp;Follow the guidance next to the Post button, post test data in the form of a datastep, example output, logic etc. &amp;nbsp;None of that code really makes any sense to me. &amp;nbsp;The first block seems to create some conditonal variables, then means those variables - this could be done in one simple SQL step. &amp;nbsp;The second block seems to be trying to put a condiiton into a macro variable, which will not work.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jun 2017 08:06:31 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-06-21T08:06:31Z</dc:date>
    <item>
      <title>How to find partial strings and count the total amount, then create a macro number?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368960#M65010</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Hello:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I have the following DATA program.&amp;nbsp; Is there a way to write the PROC SQL program list below?&amp;nbsp; Thanks.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(Name,&lt;FONT color="#800080" face="Courier New" size="2"&gt;'If_True'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; and index(Name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'kary'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;N1=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(Name,&lt;FONT color="#800080" face="Courier New" size="2"&gt;'If_False'&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; and index(Name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'Paul'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;N2=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;means&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=want &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;sum&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; N1 N2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;sum(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;case&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; find (name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'If_True'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;: N1 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;SELECT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;sum(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;case&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; find (name,&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'If_False'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;else&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;into&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;: N2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 21:52:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368960#M65010</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-20T21:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to find partial strings and count the total amount, then create a macro number?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368965#M65011</link>
      <description>&lt;P&gt;What do you think is wrong with your current SQL code? It appears to already create the two macro variables that you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 22:05:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368965#M65011</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-20T22:05:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to find partial strings and count the total amount, then create a macro number?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368977#M65013</link>
      <description>&lt;P&gt;There is nothing wrong with the SQL codes. &amp;nbsp;In fact, they are great. &amp;nbsp;I am trying to reproduce those codes based on my Data step requirement. &amp;nbsp; The SQL seems only good at finding one single string 'If_True', &amp;nbsp;but I am looking for the match both 'If_True' and 'Kary'. &amp;nbsp;I have 200 similar rows showing in data steps, that is why I'm looking for the simpler codes to accomplish the task.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 23:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368977#M65013</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-20T23:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to find partial strings and count the total amount, then create a macro number?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368981#M65014</link>
      <description>&lt;P&gt;You can include both conditions in your sql clause:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
informat name $80.;
  input name &amp;amp;;
  cards;
John If_True kary
John If_True Mary
John If_True kary
John If_True kary
Tom If_Not Carol
Tom If_Not Carol
Tom If_Not Carol
Joe If_True Jane
Joe If_False Jane
Joe If_False Paul
Joe If_False Jane
Paul If_False Jane
Joe If_False Jane
Joe If_False Jane
;

proc SQL;
SELECT
sum(case when find (name,'If_True')&amp;gt;0 and index(Name,'kary')&amp;gt;0 then 1 else 0 end) into: N1 FROM have;
SELECT
sum(case when find (name,'If_False')&amp;gt;0  and index(Name,'Paul')&amp;gt;0 then 1 else 0 end) into: N2 FROM have;
quit;

%put &amp;amp;n1;
%put &amp;amp;n2;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 23:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368981#M65014</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-06-20T23:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find partial strings and count the total amount, then create a macro number?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368982#M65015</link>
      <description>&lt;P&gt;Long, but worth reading.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.catb.org/~esr/faqs/smart-questions.html" target="_blank"&gt;http://www.catb.org/~esr/faqs/smart-questions.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 23:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/368982#M65015</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-20T23:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to find partial strings and count the total amount, then create a macro number?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/369042#M65017</link>
      <description>&lt;P&gt;What is it your actually trying to do? &amp;nbsp;Follow the guidance next to the Post button, post test data in the form of a datastep, example output, logic etc. &amp;nbsp;None of that code really makes any sense to me. &amp;nbsp;The first block seems to create some conditonal variables, then means those variables - this could be done in one simple SQL step. &amp;nbsp;The second block seems to be trying to put a condiiton into a macro variable, which will not work.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 08:06:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/369042#M65017</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-21T08:06:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to find partial strings and count the total amount, then create a macro number?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/369131#M65020</link>
      <description>&lt;P&gt;Thanks for your help, Art297&amp;nbsp; That is exactly what I want.&amp;nbsp;&amp;nbsp;&amp;nbsp; Just one more question,&amp;nbsp; is there a way to create a table to list all of the macro N? I found the table I created only show the last macro N.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc SQL;&lt;BR /&gt;SELECT&lt;BR /&gt;sum(case when find (name,'If_True')&amp;gt;0 and index(Name,'kary')&amp;gt;0 then 1 else 0 end) into: N1 FROM have;&lt;BR /&gt;SELECT&lt;BR /&gt;sum(case when find (name,'If_False')&amp;gt;0&amp;nbsp; and index(Name,'Paul')&amp;gt;0 then 1 else 0 end) into: N2 FROM have;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;%put &amp;amp;n1;&lt;BR /&gt;%put &amp;amp;n2;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 13:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-find-partial-strings-and-count-the-total-amount-then/m-p/369131#M65020</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-21T13:13:44Z</dc:date>
    </item>
  </channel>
</rss>

