<?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: Multiple Queries in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328672#M73390</link>
    <description>&lt;P&gt;The text string '&lt;SPAN&gt; ianﾞ' is not found in any of the rows of Name. &amp;nbsp;If you want to find Jian and Bian then:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if index(name,'ian') &amp;gt; 0 then ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also, good idea to post test data in the form of a datastep.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Jan 2017 09:40:39 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-01-31T09:40:39Z</dc:date>
    <item>
      <title>Multiple Queries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328665#M73388</link>
      <description>&lt;P&gt;Hello Everybody,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a new variable (Count) based on multiple queries in a group:&lt;/P&gt;&lt;P&gt;Observations are grouped by ID. Condition 1 is : Desired variable 'count' increases by 1 if variable 'Country' is US. Condition2 is if variable 'Group' is 'ABC' and variable 'Name' contains 'ian' then also count increases by 1. Something like below :&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Input&lt;/TD&gt;&lt;TD&gt;Output&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;TD&gt;Name&lt;/TD&gt;&lt;TD&gt;Group&lt;/TD&gt;&lt;TD&gt;Country&lt;/TD&gt;&lt;TD&gt;Count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1月2日&lt;/TD&gt;&lt;TD&gt;Jian&lt;/TD&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;AU&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1月3日&lt;/TD&gt;&lt;TD&gt;Bian&lt;/TD&gt;&lt;TD&gt;DEF&lt;/TD&gt;&lt;TD&gt;RU&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1月4日&lt;/TD&gt;&lt;TD&gt;Lasie&lt;/TD&gt;&lt;TD&gt;ABC&lt;/TD&gt;&lt;TD&gt;UK&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1月5日&lt;/TD&gt;&lt;TD&gt;Brat&lt;/TD&gt;&lt;TD&gt;JKL&lt;/TD&gt;&lt;TD&gt;US&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote the following program but dont know why its not giving the desired result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Out;&lt;BR /&gt;set Input ;&lt;BR /&gt;by ID Date ;&lt;BR /&gt;if first.ID then count=0;&lt;BR /&gt;if (find(Name,' ianﾞ','i') and Group = 'ABC') then count + 1 ;&lt;BR /&gt;else if Country="US" then count + 1;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 08:49:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328665#M73388</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2017-01-31T08:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Queries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328670#M73389</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;In the code you provide, there is a space before ian (and a special character after).&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 09:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328670#M73389</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-01-31T09:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Queries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328672#M73390</link>
      <description>&lt;P&gt;The text string '&lt;SPAN&gt; ianﾞ' is not found in any of the rows of Name. &amp;nbsp;If you want to find Jian and Bian then:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if index(name,'ian') &amp;gt; 0 then ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also, good idea to post test data in the form of a datastep.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2017 09:40:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328672#M73390</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-31T09:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Queries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328958#M73531</link>
      <description>Thanks...&lt;BR /&gt;Any idea how to filter the records that do not have 'ian' and group abc ??</description>
      <pubDate>Wed, 01 Feb 2017 02:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/328958#M73531</guid>
      <dc:creator>deega</dc:creator>
      <dc:date>2017-02-01T02:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Queries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/329001#M73545</link>
      <description>&lt;P&gt;You can explicitely output only the records that satisfy the condition with an "output" statement.&lt;/P&gt;
&lt;P&gt;Whenever a data step contains an output statement, the automatic output of input records&lt;/P&gt;
&lt;P&gt;is disabled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set Input;
by ID Date;
if first.ID then count=0;
if (find(Name,'ian','i') and Group = 'ABC') then do;
	count + 1 ;
	output;
end;
else if Country="US" then count + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2017 09:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/329001#M73545</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-02-01T09:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Queries</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/329003#M73546</link>
      <description>&lt;P&gt;Always a good idea to post test data, in the form of a datastep. &amp;nbsp;To get those with the string reverse the logic gate and include any extras, from:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if index(name,'ian') &amp;gt; 0 then ...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if index(name,'ian') = 0 and group ne "abc" then ...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 09:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-Queries/m-p/329003#M73546</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-01T09:16:31Z</dc:date>
    </item>
  </channel>
</rss>

