<?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: SUM OF in WHERE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579615#M164535</link>
    <description>&lt;P&gt;Subsetting if uses pure data step syntax, "where" uses SQL syntax, where the "of" construct is not available.&lt;/P&gt;
&lt;P&gt;You can automate it by retrieving the variable list from dictionary.columns into a macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :varlist separated by ',' from dictionary.columns
where
  libname = 'WORK' and memname = 'HAVE' and
  upcase(substr(name,1,1)) in ('A','B')
;
quit;

data want;
set have;
where sum(&amp;amp;varlist.) = 3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 07 Aug 2019 09:28:15 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-08-07T09:28:15Z</dc:date>
    <item>
      <title>SUM OF in WHERE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579611#M164532</link>
      <description>&lt;P&gt;Is it impossible to use SUM OF in WHERE? For example, suppose six dummy variables as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	do i=1 to 30;
		a1=ranbin(1,1,0.5);
		a2=ranbin(1,1,0.5);
		a3=ranbin(1,1,0.5);
		b1=ranbin(1,1,0.5);
		b2=ranbin(1,1,0.5);
		b3=ranbin(1,1,0.5);
		output;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The following successfully subsets by IF with SUM OF.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data usual;
	set have;
	if sum(of a: b:)=3;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, it seems WHERE does not allow SUM OF, while allows SUM per se.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	*set have(where=(sum(of a: b:)=3));
	set have;
	*where sum(of a: b:)=3;
	*where sum(of a1--b3)=3;
	where sum(a1,a2,a3,b1,b2,b3)=3;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Should I always list all the variables to use WHERE? There are too many variables to be specified. Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 09:19:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579611#M164532</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-08-07T09:19:59Z</dc:date>
    </item>
    <item>
      <title>Re: SUM OF in WHERE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579615#M164535</link>
      <description>&lt;P&gt;Subsetting if uses pure data step syntax, "where" uses SQL syntax, where the "of" construct is not available.&lt;/P&gt;
&lt;P&gt;You can automate it by retrieving the variable list from dictionary.columns into a macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select name into :varlist separated by ',' from dictionary.columns
where
  libname = 'WORK' and memname = 'HAVE' and
  upcase(substr(name,1,1)) in ('A','B')
;
quit;

data want;
set have;
where sum(&amp;amp;varlist.) = 3;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Aug 2019 09:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579615#M164535</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-07T09:28:15Z</dc:date>
    </item>
    <item>
      <title>Re: SUM OF in WHERE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579617#M164537</link>
      <description>Thanks for the considerate details. I didn't know whether WHERE uses SQL to subset.</description>
      <pubDate>Wed, 07 Aug 2019 09:51:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579617#M164537</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2019-08-07T09:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: SUM OF in WHERE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579731#M164609</link>
      <description>&lt;P&gt;where statements and where= dataset conditions work not only in data steps, but in procedure steps also. The execution of where is done by the dataset engine, and the best common denominator for table access is to use SQL, so that's what SAS does.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Aug 2019 18:44:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SUM-OF-in-WHERE/m-p/579731#M164609</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-07T18:44:53Z</dc:date>
    </item>
  </channel>
</rss>

