<?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: Where Statement with multiple variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608293#M177011</link>
    <description>&lt;P&gt;No I don't care where exactly E123-E200 in the variables code1-89 are, I just want to know how often.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I look at your first solution, I cannot figure out what the&lt;/P&gt;&lt;P&gt;where col1 between 'E123' and 'E200' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;part means - what is col1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use Your second code, in the line where you say:&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;keep&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;/* key variables here */&lt;/SPAN&gt; a_code &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which key variables do you mean? Like all the other variables I want to keep from the data?&lt;/P&gt;&lt;P&gt;The Problem is that I don't see any results. No error which is gut, but no results&lt;/P&gt;</description>
    <pubDate>Fri, 29 Nov 2019 16:59:55 GMT</pubDate>
    <dc:creator>hannah_hortlik</dc:creator>
    <dc:date>2019-11-29T16:59:55Z</dc:date>
    <item>
      <title>Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608275#M177000</link>
      <description>&lt;P&gt;Hey guys, hope you're all well.&lt;/P&gt;&lt;P&gt;I'm getting curious about a new Problem I have.&lt;/P&gt;&lt;P&gt;In my data I have 89 variables (called code1, code2 ...) , and each variable has a different value. For example the value "E123". There is always a letter and then a number, sometimes just two numbers, sometimes more.&lt;/P&gt;&lt;P&gt;I want a table, where I want to look threw all 89 variables and want to know how often there are the values "E123", "E124", ... to "E200".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = codes&lt;BR /&gt;tables (names) *(code: ) / norow nocol cumcol nocum plots=none;&lt;BR /&gt;where ('E123'&amp;lt;= code: &amp;lt;='E200');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But sas doesn't get that ":" , it's always an error. Also when I say:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data = codes&lt;BR /&gt;tables (names) *(code: ) / norow nocol cumcol nocum plots=none;&lt;BR /&gt;where ('E123'&amp;lt;= code1-89 &amp;lt;='E200'); / where ('E123'&amp;lt;= code1 - code89 &amp;lt;='E200');&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then it says, for the where statement is an numeric value needed. But when I just say: where code1='E123' it works so...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope you understand my problem and can help me,&lt;/P&gt;&lt;P&gt;thanks a lot!&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 15:59:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608275#M177000</guid>
      <dc:creator>hannah_hortlik</dc:creator>
      <dc:date>2019-11-29T15:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608279#M177002</link>
      <description>&lt;P&gt;If I am understanding this properly, I would do this in an ARRAY in a DATA step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set codes;
    array code code:;
    do i=1 to dim(code);
        if code(i) in ('E123','E124','E125', ... ,'E200') then count+1;
        /* in the above statement, you have to type in all of the values like 'E123' you want to test for */
    end;
    drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If you really want to get fancy, you could have a macro variable that contains the values 'E123' to 'E200' and then you wouldn't have to do the typing.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 16:12:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608279#M177002</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-11-29T16:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608282#M177004</link>
      <description>&lt;P&gt;Regardless of the syntax, the concept will not work.&amp;nbsp; There is no way to apply one WHERE subset to one of the tables, and a different WHERE subset to another table.&amp;nbsp; You will need to build all tables from the same set of observations.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are a few ways you could proceed.&amp;nbsp; You could use macro language to generate a separate PROC FREQ for each variable.&amp;nbsp; But here is a quick and dirty method just in case it helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value $e low-'E122' = 'Lower'   'E201'-high = 'Higher';
run;

proc freq
   tables (names) * (code: ) / norow nocol cumcol nocum plots=none;
   format code: $e.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that these tables will be inconvenient to read.&amp;nbsp; You might want to add the LIST option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;... plots=none list;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you add that, you might want to remove the table options after the "/".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the "quick and dirty" method does get you the extra two rows that you can ignore.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 16:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608282#M177004</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-11-29T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608287#M177006</link>
      <description>Well, but I don't want to type in all of the values because that will be many values &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;BR /&gt;How do I code a macro variable in this case?&lt;BR /&gt;And does that show me how often the values are in the code1-89 variables?</description>
      <pubDate>Fri, 29 Nov 2019 16:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608287#M177006</guid>
      <dc:creator>hannah_hortlik</dc:creator>
      <dc:date>2019-11-29T16:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608288#M177007</link>
      <description>&lt;P&gt;Do you really care whether E123 appears in CODE1 instead of CODE89 ?&lt;/P&gt;
&lt;P&gt;Transpose and count.&amp;nbsp; If you have variables that uniquely identify the rows in your dataset you can use PROC TRANSPOSE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=have out=tall ;
  by keys ;
  var code1-code89 ;
run;
proc freq data=tall;
  where col1 between 'E123' and 'E200' ;
   tables col1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If not then transpose with a data step.&amp;nbsp; In that case you could keep TALL smaller by only writing the codes you want to count.&amp;nbsp; You could even make it a view instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tall / view=tall;
  set have;
  array code [89];
  do index=1 to dim(code);
     if 'E123' &amp;lt;= code[index]  &amp;lt;= 'E200' then do;
         a_code = code[index];
         output;
    end;
  end;
  keep /* key variables here */ a_code ;
run;
proc freq data=tall;
  tables a_code;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 16:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608288#M177007</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-29T16:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608290#M177008</link>
      <description>&lt;P&gt;I don't get what I get then I'm sorry.&lt;/P&gt;&lt;P&gt;Because in my result-table I still see the single values "E123" but I only want to see how many not which. And I don't understand what I get out of that value line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe, it would be more easy to create a new value, called "new" and in that value all codes code1-code89 are included? And then say where new = "E123" - E200"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or is it not at all possible with the where statement?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 16:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608290#M177008</guid>
      <dc:creator>hannah_hortlik</dc:creator>
      <dc:date>2019-11-29T16:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608293#M177011</link>
      <description>&lt;P&gt;No I don't care where exactly E123-E200 in the variables code1-89 are, I just want to know how often.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I look at your first solution, I cannot figure out what the&lt;/P&gt;&lt;P&gt;where col1 between 'E123' and 'E200' ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;part means - what is col1?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use Your second code, in the line where you say:&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token keyword"&gt;keep&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;/* key variables here */&lt;/SPAN&gt; a_code &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which key variables do you mean? Like all the other variables I want to keep from the data?&lt;/P&gt;&lt;P&gt;The Problem is that I don't see any results. No error which is gut, but no results&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 16:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608293#M177011</guid>
      <dc:creator>hannah_hortlik</dc:creator>
      <dc:date>2019-11-29T16:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608296#M177012</link>
      <description>&lt;P&gt;Looks like I didn't understand the problem fully.&amp;nbsp; Based on that description, try modifying the format:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
   value $e 
   low-'E122' = 'Lower'   
   'E123'-'E200' = 'E123 to E200' 
   'E201'-high = 'Higher';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That will collapse the various values into a single row of the table.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 17:07:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608296#M177012</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-11-29T17:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608298#M177013</link>
      <description>&lt;P&gt;If you don't tell PROC TRANSPOSE what prefix use when naming the resulting columns it will name them COL1, COL2 , ...&amp;nbsp; So the value from the first observation in a group goes into COL1 from the second into COL2. etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is why for your problem you need BY variables to make so that only one variable is created.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the data step to transpose then make sure to use the variable you create in that step in the proc freq step.&amp;nbsp; If you want to tall dataset/view to be useful include any other variables that are useful.&amp;nbsp; Instead of KEEP you could also use DROP to remove the original 89 code variables.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 17:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608298#M177013</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-29T17:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608316#M177020</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296533"&gt;@hannah_hortlik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;(...) For example the value "E123". There is always a letter and then a number, sometimes just two numbers, sometimes more.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you mean two or more &lt;EM&gt;digits&lt;/EM&gt;, i.e., the variables in question may contain codes like "E15" or "E1234"? Then you need to be careful with range specifications: The condition &lt;FONT face="courier new,courier"&gt;"E123" &amp;lt;= code &amp;lt;= "E200"&lt;/FONT&gt;&amp;nbsp;(applied to a sufficiently long character variable &lt;FONT face="courier new,courier"&gt;code&lt;/FONT&gt;) would include codes E13 - E20 as well as E1230 - E1999,&amp;nbsp;E12300 - E19999, etc. (and E2). Same with "&lt;FONT face="courier new,courier"&gt;between&lt;/FONT&gt; ... &lt;FONT face="courier new,courier"&gt;and&lt;/FONT&gt;" and with the range &lt;FONT face="courier new,courier"&gt;'E123'-'E200'&lt;/FONT&gt; in a format definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To avoid this, you can rewrite the condition as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;code=:'E' &amp;amp; 123&amp;lt;=input(substr(code,2),32.)&amp;lt;=200&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(i.e., the value of&amp;nbsp;&lt;FONT face="courier new,courier"&gt;code&lt;/FONT&gt;&amp;nbsp;is an "E" followed by a number between 123 and 200).&lt;/P&gt;</description>
      <pubDate>Fri, 29 Nov 2019 18:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608316#M177020</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-11-29T18:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608471#M177093</link>
      <description>&lt;P&gt;Am I understanding it right?&lt;/P&gt;&lt;P&gt;I get a table, where I see how many values are between E123 and E200, and how many are higher? cause that's the name of the 2 columns of my table.&lt;/P&gt;&lt;P&gt;But I don't know why but the result is simply wrong - for code_1 if have 2 values (E125 and E 150), but in the table there is just "1. And I have 20 columns but it says "Higher = 12" and "total = 13".&lt;/P&gt;&lt;P&gt;I don't know where these numbers are coming from&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 18:43:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608471#M177093</guid>
      <dc:creator>hannah_hortlik</dc:creator>
      <dc:date>2019-11-30T18:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608474#M177095</link>
      <description>&lt;P&gt;Okay so I use this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; new &lt;SPAN class="token operator"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;set&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token statement"&gt;array&lt;/SPAN&gt; code &lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;89&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  do &lt;SPAN class="token function"&gt;index&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt; to &lt;SPAN class="token function"&gt;dim&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;code&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
     &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'E123'&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; code&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;index&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;  &lt;SPAN class="token operator"&gt;&amp;lt;=&lt;/SPAN&gt; &lt;SPAN class="token string"&gt;'E200'&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; do&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
         a_code &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; code&lt;SPAN class="token punctuation"&gt;[&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;index&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;]&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
         output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
    end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  end&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;keep&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;/* key variables here */&lt;/SPAN&gt; a_code &lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;freq&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;new&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="token keyword"&gt;tables&lt;/SPAN&gt; a_code&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And get a table with a new line called "a_code" where are only the codes I defined (E123-E200). And as result from the proc freq code I see, how often there is E123, how often E124, ...&lt;/P&gt;&lt;P&gt;But now let's say, to make it more easy, I define E123 - E124 and there is 5 times E123 and 6 times E124. I want to know, how often there are the values between E123 and E124 (11 times in this case) but not seperated - just together.&lt;/P&gt;&lt;P&gt;Not liket his:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a_code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Frequency&lt;/P&gt;&lt;P&gt;E123&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;E124&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just:&lt;/P&gt;&lt;P&gt;a_code&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Frequency&lt;/P&gt;&lt;P&gt;E123-124&amp;nbsp;&amp;nbsp;&amp;nbsp; 11&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example! So I want to know the total number how often there are values between E123 and E200, but I don't want to see/know, how often the values are there individually. Hope you get what I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But already Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 18:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608474#M177095</guid>
      <dc:creator>hannah_hortlik</dc:creator>
      <dc:date>2019-11-30T18:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608475#M177096</link>
      <description>&lt;P&gt;The simplest way is to just count in the data step instead of writing out the full list and then using PROC FREQ to count.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data count;
  set have end=eof;
  array code [89];
  do index=1 to dim(code);
     if 'E123' &amp;lt;= code[index]  &amp;lt;= 'E200' then count+1;
  end;  
  if eof then do;
    put count=;
    output;
  end;
  keep count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The more general way would be to make a format that maps all of those values to the same string.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value $mygroup 
  'E123'  - 'E200' = 'E123 - E200'
;
proc freq data=new;
  tables a_code;
  format a_code $mygroup.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 30 Nov 2019 19:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608475#M177096</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-30T19:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: Where Statement with multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608571#M177129</link>
      <description>&lt;P&gt;Well, you just saved my ass. And day and week. Thank you so much, that is exactly what I want.&lt;/P&gt;</description>
      <pubDate>Sun, 01 Dec 2019 12:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-Statement-with-multiple-variables/m-p/608571#M177129</guid>
      <dc:creator>hannah_hortlik</dc:creator>
      <dc:date>2019-12-01T12:07:47Z</dc:date>
    </item>
  </channel>
</rss>

