<?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: Proc Means with Multiple Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641768#M191339</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data = heart (where=(weight ge 140 and cholesterol GE 140)) noprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Naturally the above syntax is an example. You should modify it to whatever the proper condition is for your problem.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Tue, 21 Apr 2020 23:10:12 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-04-21T23:10:12Z</dc:date>
    <item>
      <title>Proc Means with Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641752#M191328</link>
      <description>&lt;P&gt;Hello Everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was hoping someone could help me understand where I am going wrong when using proc means&lt;/P&gt;
&lt;P&gt;with multiple variables. I am using the sashelp.heart dataset. When I use the code below&lt;/P&gt;
&lt;P&gt;with one variable the code works fine.&lt;/P&gt;
&lt;PRE&gt;proc means data = heart (where=(weight GE 140)) noprint;&lt;BR /&gt;	var weight; &lt;BR /&gt;	by sex; &lt;BR /&gt;	output out = out (drop=_type_ _freq_);&lt;BR /&gt;run; &lt;/PRE&gt;
&lt;P&gt;However, when I try to use the code with multiple variables (code below) I get an error message.&amp;nbsp; I have&lt;/P&gt;
&lt;P&gt;tried adding a comma between the variables however, I still get the error. Could someone assist me with this please?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc means data = heart (where=(weight cholesterol GE 140)) noprint;&lt;BR /&gt;	var weight cholesterol; &lt;BR /&gt;	by sex; &lt;BR /&gt;	output out = out (drop=_type_ _freq_);&lt;BR /&gt;run; &lt;/PRE&gt;
&lt;P&gt;The error message is:&amp;nbsp;&lt;/P&gt;
&lt;DIV id="sasLogError1_1587502659702" class="sasError"&gt;ERROR: Syntax error while parsing WHERE clause.&lt;/DIV&gt;
&lt;DIV id="sasLogError2_1587502659702" class="sasError"&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, -, /, &amp;lt;, &amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE,&lt;/DIV&gt;
&lt;DIV class="sasError"&gt;LT, NE, OR, ^=, |, ||, ~=.&lt;/DIV&gt;
&lt;DIV id="sasLogError3_1587502659702" class="sasError"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Apr 2020 21:06:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641752#M191328</guid>
      <dc:creator>luvscandy27</dc:creator>
      <dc:date>2020-04-21T21:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means with Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641753#M191329</link>
      <description>&lt;P&gt;This is not valid code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where=(weight cholesterol GE 140)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the condition you are actually trying to test?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2020 21:14:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641753#M191329</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-21T21:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means with Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641754#M191330</link>
      <description>&lt;P&gt;In&lt;/P&gt;
&lt;PRE&gt;(weight cholesterol GE 140)&lt;/PRE&gt;
&lt;P&gt;what condition are you placing on weight? There is none. Plus when you have two or more variables you need to indicate the relationship between two comparisons such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;weight ge 100 and cholesterol ge 140&amp;nbsp; =&amp;gt; records with individuals having weight ge 100 AND cholesterol ge 160&lt;/P&gt;
&lt;P&gt;or perhaps&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;weight ge 100 OR cholesterol ge 140&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you meant to have the same range for both variables then you need to list both explicitly.&lt;/P&gt;
&lt;P&gt;A variable with no condition will be treated as true if the value is not 0 or missing. But again if multiple variables are used you need to specify the relationship between the two (or more variables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When showing us an error message you should should copy the entire proc or datastep involved and paste into a code box opened using the &amp;lt;/&amp;gt; or "running man" icon on the forum.&lt;/P&gt;
&lt;P&gt;If you look at the way it appeared in the log, which should be similar to the following then you see that there were a number of underscore characters under the word cholesterol. That means the error of an expected character or operation is before that word. In this case likely was an "AND" or "OR" for which comparison you wanted between the two variables.&lt;/P&gt;
&lt;PRE&gt;108  proc means data = sashelp.heart (where=(weight cholesterol GE 140)) noprint;
                                                    -----------
                                                    22
                                                    76
ERROR: Syntax error while parsing WHERE clause.
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, (, *, **, +, -, /, &amp;lt;, &amp;lt;=,
              &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;=, AND, EQ, GE, GT, LE, LT, NE, OR, ^=, |, ||, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
109     var weight cholesterol;
110     by sex;
111     output out = out (drop=_type_ _freq_);
112  run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.OUT may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.

&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Apr 2020 21:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641754#M191330</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-04-21T21:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means with Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641755#M191331</link>
      <description>I would like to get all the observations with weight, systolic, and&lt;BR /&gt;cholesterol greater than 140. I would like the count and mean for the three&lt;BR /&gt;variables.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Apr 2020 21:26:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641755#M191331</guid>
      <dc:creator>luvscandy27</dc:creator>
      <dc:date>2020-04-21T21:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Means with Multiple Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641768#M191339</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc means data = heart (where=(weight ge 140 and cholesterol GE 140)) noprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Naturally the above syntax is an example. You should modify it to whatever the proper condition is for your problem.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Apr 2020 23:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Means-with-Multiple-Variables/m-p/641768#M191339</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-21T23:10:12Z</dc:date>
    </item>
  </channel>
</rss>

