<?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: Running average score variable based on data getting error messages in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246715#M46199</link>
    <description>&lt;P&gt;To build on what mohamed said, with this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CourseAvg = .1Quiz1 + .1Quiz2 + .1Quiz3 + .1Quiz4 + .2midterm + .2project + .2final;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are telling SAS to look for a variable called ".1Quiz1", a variable called ".1Quiz2", etc. These are not valid variable names in SAS (which must begin with an English letter or underscore). You need to tell SAS that you are applying a mathematical operation to the variable Quiz1, namely that you want to multiply it by 0.1 (and so on).&lt;/P&gt;</description>
    <pubDate>Thu, 28 Jan 2016 18:36:36 GMT</pubDate>
    <dc:creator>RyanSimmons</dc:creator>
    <dc:date>2016-01-28T18:36:36Z</dc:date>
    <item>
      <title>Running average score variable based on data getting error messages</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246711#M46195</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Working on an assignment and i keep getting an error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data scores3;&lt;BR /&gt;infile datalines delimiter= '/' dsd;&lt;/P&gt;&lt;P&gt;input StudentID $ Quiz1 Quiz2 Quiz3 Quiz4 Midterm Project Final;&lt;/P&gt;&lt;P&gt;CourseAvg = .1Quiz1 + .1Quiz2 + .1Quiz3 + .1Quiz4 + .2midterm + .2project + .2final;&lt;BR /&gt;datalines;&lt;BR /&gt;JK/89/100/88/91/100/87/87&lt;BR /&gt;DS/100/95/97/69/100/88/85&lt;BR /&gt;SR/100/84/98/69/0/./89&lt;BR /&gt;RL/99/0/94/0/100/77/55&lt;BR /&gt;MZ/100/100/92/97/100/100/98&lt;BR /&gt;BB/88/./80/52/100/78/76&lt;BR /&gt;AC/100/100/100/98/100/100/98&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc print data=scores3;&lt;BR /&gt;var StudentID CourseAvg;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the above code keeps coming back with an error message and I dont understand what the error in my code is.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="sasSource"&gt;61 CourseAvg = .1Quiz1 + .1Quiz2 + .1Quiz3 + .1Quiz4 + .2midterm + .2project + .2final;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_____ _____ _____ _____ _______&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22 22 22 22 22&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;61 CourseAvg = .1Quiz1 + .1Quiz2 + .1Quiz3 + .1Quiz4 + .2midterm + .2project + .2final;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_______&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV 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;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;LE, LT, MAX, MIN, NE, NG, NL, OR, ^=, |, ||, ~=.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;61 CourseAvg = .1Quiz1 + .1Quiz2 + .1Quiz3 + .1Quiz4 + .2midterm + .2project + .2final;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;_____&lt;/DIV&gt;&lt;DIV class="sasError"&gt;22&lt;/DIV&gt;&lt;DIV 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;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN,&lt;/DIV&gt;&lt;DIV class="sasError"&gt;LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;62 datalines;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: The data set WORK.SCORES3 may be incomplete. When this step was stopped there were 0 observations and 9 variables.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: Data set WORK.SCORES3 was not replaced because this step was stopped.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.08 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.07 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;these are the warning and error messages recieved after inputing the code.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;I really dont understand the error in my &amp;nbsp;code. if someone could help that would be greatl appreciated.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 Jan 2016 18:19:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246711#M46195</guid>
      <dc:creator>MadQuidd</dc:creator>
      <dc:date>2016-01-28T18:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: Running average score variable based on data getting error messages</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246712#M46196</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70676"&gt;@MadQuidd&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CourseAvg = .1Quiz1 + .1Quiz2 + .1Quiz3 + .1Quiz4 + .2midterm + .2project + .2final;&lt;/P&gt;
&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have two problem in this statment&lt;/P&gt;
&lt;P&gt;- Where is the multiplication sign between numbers&lt;/P&gt;
&lt;P&gt;- As you have Missing values you better use the &lt;STRONG&gt;SUM()&lt;/STRONG&gt; function as it add missing. Not like the &lt;STRONG&gt;+&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CourseAvg = sum(.1*Quiz1 , .1*Quiz2 ,.1*Quiz3 , .1*Quiz4 , .2*midterm , .2*project , .2*final);
&lt;/CODE&gt;&lt;/PRE&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;</description>
      <pubDate>Thu, 28 Jan 2016 18:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246712#M46196</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-28T18:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Running average score variable based on data getting error messages</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246715#M46199</link>
      <description>&lt;P&gt;To build on what mohamed said, with this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CourseAvg = .1Quiz1 + .1Quiz2 + .1Quiz3 + .1Quiz4 + .2midterm + .2project + .2final;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are telling SAS to look for a variable called ".1Quiz1", a variable called ".1Quiz2", etc. These are not valid variable names in SAS (which must begin with an English letter or underscore). You need to tell SAS that you are applying a mathematical operation to the variable Quiz1, namely that you want to multiply it by 0.1 (and so on).&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 18:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246715#M46199</guid>
      <dc:creator>RyanSimmons</dc:creator>
      <dc:date>2016-01-28T18:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Running average score variable based on data getting error messages</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246727#M46205</link>
      <description>&lt;P&gt;Kindly, if you got answers to your questions. Close the thread, by choosing one&amp;nbsp;of the replies as "Accepted Answer".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Jan 2016 19:01:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246727#M46205</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-01-28T19:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: Running average score variable based on data getting error messages</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246857#M46249</link>
      <description>&lt;P&gt;One more remark (although the thread has been "closed" already ...):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If variable CourseAvg may be used for further processing (e.g. "&lt;FONT face="courier new,courier"&gt;if CourseAvg&amp;gt;30 then&lt;/FONT&gt; ...") I would strongly recommend to round it to a suitable number of decimals in order to avoid (!)&amp;nbsp;rounding errors (due to numeric representation issues).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simplified example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input id quiz1-quiz3;
cards;
1 35 31 29
2 50 20 30
3 82 53 16
;

data eval;
set test;
avg=sum(.1*Quiz1, .2*Quiz2, .7*Quiz3); /* Risky! No rounding! */
length result $10;
     if avg&amp;gt;30 then result='Pass';
else if avg&amp;lt;30 then result='Fail';
else if avg=30 then result='Borderline';
run;

proc print data=eval noobs;
format avg best32.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;PRE&gt;id    quiz1    quiz2    quiz3                                 avg    result

 1      35       31       29                                   30    Fail
 2      50       20       30                                   30    Borderline
 3      82       53       16                                   30    Pass&lt;/PRE&gt;
&lt;P&gt;As you can see, the three fictitious students are assigned three different results. However,&amp;nbsp;their AVG scores should be &lt;EM&gt;exactly equal&lt;/EM&gt; to 30 in all three cases&amp;nbsp;(simple calculation, e.g. 8.2+10.6+11.2=30 for ID=3) and, indeed, this is what PROC PRINT shows, even with a very long display format such as BEST32..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RESULT values of students 1 and 3 are incorrect due to tiny rounding errors from the calculation of AVG, which lead to slight deviations from the mathematically correct results (AVG=30):&amp;nbsp;For the computer, ID 1 has AVG=29.999999999999996447... (hence &amp;lt;30) and ID 3 has AVG=30.000000000000003552... (hence &amp;gt;30).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This severe issue (student 1 could file a lawsuit!) could be avoided easily by defining&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;avg=&lt;STRONG&gt;round(&lt;/STRONG&gt;sum(.1*Quiz1, .2*Quiz2, .7*Quiz3)&lt;STRONG&gt;, 1e-9)&lt;/STRONG&gt;;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The small rounding unit (one billionth) is sufficient to flatten the rounding errors (of size 3.55E-15) and would not distort the results either, even if Quiz1-Quiz3 were not integers, but had, say, three decimals.&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;</description>
      <pubDate>Fri, 29 Jan 2016 10:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-average-score-variable-based-on-data-getting-error/m-p/246857#M46249</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-01-29T10:21:29Z</dc:date>
    </item>
  </channel>
</rss>

