<?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: Using temporary array to score a test in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774935#M246327</link>
    <description>&lt;P&gt;Wrong because you get only one value in variable SCORES for each student when you are expecting 20 values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or wrong because you want the sum of the 20 zero/one values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or wrong for some other reason?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Oct 2021 17:20:51 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-10-18T17:20:51Z</dc:date>
    <item>
      <title>Using temporary array to score a test</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774931#M246325</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stan;
array Key[20] $ _temporary_ ('A','B','C','D','C','B','A','D','B','A','A','C','B','D','D','B','A','A','B','B');
array Question[20] $;
input Student_ID $ Gender $ Question[*];
Scores = 0;
do i = 1 to 20;
if Question[i] eq Key[i] then Scores = 1;
end;
drop i;
datalines;
A1 Female A B A D B C D A A A C D B C A C C B D A
A2 Female B C D A A A B C D A D C D B D A A D C D
A3 Male C C C A A B D B D B C D C D C A A D A A
A4 Male A D A C C C B D C A B A C A D D A B A C
;
proc print data = stan;
title "total correct questions by item";
var Student_ID Scores: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to score a test for 4 people by using a temporary array.&amp;nbsp;The outputs should show each grade for each student, indicated by a 1 or a 0.&amp;nbsp;However, my current results are completely wrong. I think my problem comes from the proc print part but i don't know where it is wrong. Any help? Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 17:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774931#M246325</guid>
      <dc:creator>aabbccwyt</dc:creator>
      <dc:date>2021-10-18T17:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using temporary array to score a test</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774935#M246327</link>
      <description>&lt;P&gt;Wrong because you get only one value in variable SCORES for each student when you are expecting 20 values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or wrong because you want the sum of the 20 zero/one values?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or wrong for some other reason?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 17:20:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774935#M246327</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-18T17:20:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using temporary array to score a test</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774937#M246329</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It is wrong because I'm getting only 1 value for each student when I'm expecting 20 values.&lt;/P&gt;
&lt;P&gt;To be more specific, here is what I have&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-10-19 at 1.24.09 AM.png" style="width: 524px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64822i026EBFFA0650B405/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-10-19 at 1.24.09 AM.png" alt="Screen Shot 2021-10-19 at 1.24.09 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 17:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774937#M246329</guid>
      <dc:creator>aabbccwyt</dc:creator>
      <dc:date>2021-10-18T17:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using temporary array to score a test</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774942#M246331</link>
      <description>&lt;P&gt;You don't have 20 score values so why would you expect 20 values, you only have 1 score value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want 20 you need to create another array to hold those twenty values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;FYI - IMO this is easier if you transpose and merge rather than an array. Easier to summarize by question later on too to see which questions are harder than others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292388"&gt;@aabbccwyt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;It is wrong because I'm getting only 1 value for each student when I'm expecting 20 values.&lt;/P&gt;
&lt;P&gt;To be more specific, here is what I have&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-10-19 at 1.24.09 AM.png" style="width: 524px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64822i026EBFFA0650B405/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2021-10-19 at 1.24.09 AM.png" alt="Screen Shot 2021-10-19 at 1.24.09 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Oct 2021 17:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774942#M246331</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-18T17:28:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using temporary array to score a test</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774944#M246333</link>
      <description>&lt;P&gt;You need an ARRAY to store the 20 scores.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data stan;
    array Key[20] $ _temporary_ ('A','B','C','D','C','B','A','D','B','A','A','C','B','D','D','B','A','A','B','B');
    array scores[20];
    array Question[20] $;
    input Student_ID $ Gender $ Question[*];
    do i = 1 to 20;
        Scores[i] = (Question[i] eq Key[i]);
    end;
    drop i;
datalines;
A1 Female A B A D B C D A A A C D B C A C C B D A
A2 Female B C D A A A B C D A D C D B D A A D C D
A3 Male C C C A A B D B D B C D C D C A A D A A
A4 Male A D A C C C B D C A B A C A D D A B A C
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Oct 2021 17:29:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-temporary-array-to-score-a-test/m-p/774944#M246333</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-10-18T17:29:32Z</dc:date>
    </item>
  </channel>
</rss>

