<?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 specify list of variables in a where statement in proc freq in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820267#M81893</link>
    <description>&lt;P&gt;You cannot use variable lists in WHERE statement.&amp;nbsp; Use the IF statement in a data step instead.&amp;nbsp; You could create a view to avoid replicating the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But also you&amp;nbsp;cannot use more than one variable with LIKE operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to exclude the whole observation if ANY of those 25 variables have that value?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might try the WHICHC() function instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data no_J45 / view=no_j45 ;
  set LIB.LIB21;
  if 0 = whichc('j45', of diag_code_1-diag_code_25);
run;

PROC FREQ DATA=no_j45;
  TABLE year;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps INDEX() or FIND() and CATX().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if 0 = index('j45',catx('|', of diag_code_1-diag_code_25));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to just exclude the individual values?&lt;/P&gt;
&lt;P&gt;In that case you might need to transpose first.&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jun 2022 15:16:24 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-06-24T15:16:24Z</dc:date>
    <item>
      <title>How to specify list of variables in a where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820262#M81891</link>
      <description>&lt;P&gt;Is it possible to specify a list of variables in a 'where' statement in proc freq without listing them all?&lt;/P&gt;
&lt;P&gt;I want to specify variables diag_code_1 to diag_code_25, but using a hyphen doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FREQ DATA=LIB.LIB21 (where=(diag_code_1-diag_code_25 not like 'j45'));&lt;BR /&gt;TABLE year;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 15:01:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820262#M81891</guid>
      <dc:creator>Angmar</dc:creator>
      <dc:date>2022-06-24T15:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify list of variables in a where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820266#M81892</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ DATA=LIB.LIB21 (where=find((catx("|", of diag_code_1-diag_code_25), 'J45', 'it') &amp;gt;0));
TABLE year;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Something like this?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 15:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820266#M81892</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-06-24T15:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify list of variables in a where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820267#M81893</link>
      <description>&lt;P&gt;You cannot use variable lists in WHERE statement.&amp;nbsp; Use the IF statement in a data step instead.&amp;nbsp; You could create a view to avoid replicating the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But also you&amp;nbsp;cannot use more than one variable with LIKE operator.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to exclude the whole observation if ANY of those 25 variables have that value?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might try the WHICHC() function instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data no_J45 / view=no_j45 ;
  set LIB.LIB21;
  if 0 = whichc('j45', of diag_code_1-diag_code_25);
run;

PROC FREQ DATA=no_j45;
  TABLE year;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps INDEX() or FIND() and CATX().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if 0 = index('j45',catx('|', of diag_code_1-diag_code_25));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you trying to just exclude the individual values?&lt;/P&gt;
&lt;P&gt;In that case you might need to transpose first.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 15:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820267#M81893</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-24T15:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify list of variables in a where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820269#M81894</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ DATA=LIB.LIB21 (where=find((catx("|", of diag_code_1-diag_code_25), 'J45', 'it') &amp;gt;0));
TABLE year;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Something like this?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think parentheses are in the wrong spot&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FREQ DATA=LIB.LIB21 (where=(find(catx("|", of diag_code_1-diag_code_25), 'J45', 'it') &amp;gt;0));
    TABLE year;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 24 Jun 2022 15:31:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820269#M81894</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-24T15:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify list of variables in a where statement in proc freq</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820359#M81895</link>
      <description>Also you could use IN operator.&lt;BR /&gt;&lt;BR /&gt;data no_J45 / view=no_j45 ;&lt;BR /&gt;  set LIB.LIB21;&lt;BR /&gt; array x{*} $ diag_code_1-diag_code_25 ;&lt;BR /&gt;  if   'j45' in x ;&lt;BR /&gt;run;</description>
      <pubDate>Sat, 25 Jun 2022 09:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-list-of-variables-in-a-where-statement-in-proc/m-p/820359#M81895</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-06-25T09:45:42Z</dc:date>
    </item>
  </channel>
</rss>

