<?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: Scoring Survey Questionnaire Responses (MEPA) in SAS Software for Learning Community</title>
    <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Scoring-Survey-Questionnaire-Responses-MEPA/m-p/936491#M1989</link>
    <description>&lt;P&gt;Thank you so much!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jul 2024 15:27:52 GMT</pubDate>
    <dc:creator>chester2018</dc:creator>
    <dc:date>2024-07-20T15:27:52Z</dc:date>
    <item>
      <title>Scoring Survey Questionnaire Responses (MEPA)</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Scoring-Survey-Questionnaire-Responses-MEPA/m-p/936289#M1987</link>
      <description>&lt;P&gt;Hi! I'm not sure what's wrong with my SAS code! I'm trying to score the MEPA (Mediterranean Eating Pattern for Americans), but my calculations aren't adding up! I'll show some examples!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For Cheese, if a participant eats more than 4 servings of cheese a day/week, then they have a 0. If they have 4 or less, then they have a 1. And butter and nuts have a similar scoring.&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;data MEPA.scores;
	set MEPA.scores;
	if (cheese_dy gt 4) then cheese_score =0;
	else if (cheese_dy le 4) then cheese_score = 1;
	else if (cheese_dy=0 and cheese_wk le 4) then cheese_score = 1;
	else if (cheese_dy=0 and cheese_wk gt 4) then cheese_score = 0;
	else if (cheese_dy=. and cheese_wk=.) then cheese_score = 0;
run;

data MEPA.scores;
	set MEPA.scores;
	if (butter_dy &amp;gt; 5) then butter_score =0;
	else if (butter_dy le 5) then butter_score = 1;
	else if (butter_dy=0 and butter_wk le 5) then butter_score = 1;
	else if (butter_dy=0 and butter_wk &amp;gt; 5) then butter_score = 0;
	else if (butter_dy=. and butter_wk=.) then butter_score = 0;
run;

data  MEPA.scores;
	set  MEPA.scores;
	if (nuts_dy ge 4) then nuts_score =1;
	else if (nuts_dy &amp;lt; 4) then nuts_score = 0;
	else if (nuts_dy=0 and nuts_wk &amp;lt; 4) then nuts_score = 0;
	else if (nuts_dy=0 and nuts_wk ge 4) then nuts_score = 1;
	else if (nuts_dy=. and nuts_wk=.) then nuts_score = 0;
run;&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;For some reason when I score my questionnaire, these variables are the ones that aren't getting the proper score. One participant indicated they consumed 5 servings of nuts_wk, and yet their nuts_score was calculated as 0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hopefully my explanation and the questionnaire makes sense!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 21:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Scoring-Survey-Questionnaire-Responses-MEPA/m-p/936289#M1987</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2024-07-18T21:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Scoring Survey Questionnaire Responses (MEPA)</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Scoring-Survey-Questionnaire-Responses-MEPA/m-p/936296#M1988</link>
      <description>&lt;P&gt;First a very serious warning where you may have damaged your data in an earlier test or attempt:&lt;/P&gt;
&lt;P&gt;Use of code with the output data set the same as the input means the OUTPUT version completely replaces input.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data somename;
    set somename;
&lt;/PRE&gt;
&lt;P&gt;So a logic error or just running the same code repeatedly that modifies an existing variable can result is multiple changes and unexpected results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of reusing the same data set create a new one from the input.&lt;/P&gt;
&lt;P&gt;ADD code the data step to avoid creating multiple unneeded datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run this code an share the results. It may show you where you have problems easily:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc freq data=mepa.scores;
   tables cheese_dy*cheese_wk*cheese_score
             butter_dy*butter_wk*butter_score
             nuts_dy*nuts_wk*nuts_score
            / list missing;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You do have a problem with the LT or LE for the _dy variables. Missing is always less than anything.&lt;/P&gt;
&lt;P&gt;So the following is true when Cheese_dy is missing.&lt;/P&gt;
&lt;PRE&gt; if (cheese_dy le 4)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;You would need to make these something like the following to handle missing correctly:&lt;/P&gt;
&lt;PRE&gt; if (0 le cheese_dy le 4) &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 22:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Scoring-Survey-Questionnaire-Responses-MEPA/m-p/936296#M1988</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-18T22:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: Scoring Survey Questionnaire Responses (MEPA)</title>
      <link>https://communities.sas.com/t5/SAS-Software-for-Learning/Scoring-Survey-Questionnaire-Responses-MEPA/m-p/936491#M1989</link>
      <description>&lt;P&gt;Thank you so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2024 15:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Software-for-Learning/Scoring-Survey-Questionnaire-Responses-MEPA/m-p/936491#M1989</guid>
      <dc:creator>chester2018</dc:creator>
      <dc:date>2024-07-20T15:27:52Z</dc:date>
    </item>
  </channel>
</rss>

