<?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 Please help in ARRAY problem in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295101#M61629</link>
    <description>&lt;P&gt;The ascii data file called grades.dat contains five exam scores (Score1, Score2, ..., Score5) for each of four students in a class. The first column contains the student id number (ID). The passing grade on each of the five exams was determined to be 65, 70, 60, 75, and 66, respectively. Your job is to read the ascii data into a temporary SAS data set called answers. Then, determine the number of exams passed by each student (Passed). In doing so: you should take advantage of arrays wherever possible you should take advantage of shortcut lists, such as numbered range lists, named range lists, or special name lists, wherever possible you should use temporary array elements wherever possible you should use iterative DO loops wherever possible When all is said and done, your answers data set should contain seven variables: ID (student id number), the five exam grades (Score1, Score2, ..., Score5), and the number of exams each student passed (Passed). Print the resulting answers data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;grades.dat datalines are :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;001 50 70 62 78 85&lt;BR /&gt;002 90 86 87 91 94&lt;BR /&gt;003 63 72 58 73 68&lt;BR /&gt;004 60 68 59 70 65&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply,&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2016 16:15:25 GMT</pubDate>
    <dc:creator>Saurav</dc:creator>
    <dc:date>2016-08-30T16:15:25Z</dc:date>
    <item>
      <title>Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295101#M61629</link>
      <description>&lt;P&gt;The ascii data file called grades.dat contains five exam scores (Score1, Score2, ..., Score5) for each of four students in a class. The first column contains the student id number (ID). The passing grade on each of the five exams was determined to be 65, 70, 60, 75, and 66, respectively. Your job is to read the ascii data into a temporary SAS data set called answers. Then, determine the number of exams passed by each student (Passed). In doing so: you should take advantage of arrays wherever possible you should take advantage of shortcut lists, such as numbered range lists, named range lists, or special name lists, wherever possible you should use temporary array elements wherever possible you should use iterative DO loops wherever possible When all is said and done, your answers data set should contain seven variables: ID (student id number), the five exam grades (Score1, Score2, ..., Score5), and the number of exams each student passed (Passed). Print the resulting answers data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;grades.dat datalines are :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;001 50 70 62 78 85&lt;BR /&gt;002 90 86 87 91 94&lt;BR /&gt;003 63 72 58 73 68&lt;BR /&gt;004 60 68 59 70 65&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 16:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295101#M61629</guid>
      <dc:creator>Saurav</dc:creator>
      <dc:date>2016-08-30T16:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295103#M61630</link>
      <description>&lt;P&gt;We can't help without your input dataset.&lt;/P&gt;
&lt;P&gt;Please supply the contents of work.score in a data step with cards;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 11:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295103#M61630</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-30T11:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295109#M61632</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry, your question is not clear. &amp;nbsp;Post test data (form of a datastep). &amp;nbsp;And what the output should look like. &amp;nbsp;It looks like from what you have posted there is that the output statement appears before the assignment of passed in:&lt;/P&gt;
&lt;P&gt;output;&lt;BR /&gt;passedin=x+y+z+a+b;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace with:&lt;/P&gt;
&lt;P&gt;passedin=x+y+z+a+b;&lt;/P&gt;
&lt;P&gt;output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, not sure what your code is trying to do (without test data and required output), but why not just:&lt;/P&gt;
&lt;PRE&gt;data want;
  set score;
  array score(5) score1-score5;
  passedin=0;
  if score(1) ge 65 then passedin=sum(passedin,1);
  if score(2) ge 70 then passedin=sum(passedin,1);
  if score(3) ge 60 then passedin=sum(passedin,1);
  if score(4) ge 75 then passedin=sum(passedin,1);
  if score(5) ge 66 then passedin=sum(passedin,1);
  output;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 Aug 2016 11:26:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295109#M61632</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-08-30T11:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295146#M61645</link>
      <description>&lt;P&gt;To answer your original question, using ELSE is incorrect.&amp;nbsp; Your program must examine all the scores, and ELSE prevents that once the first true comparison has been found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are other errors as well.&amp;nbsp; RETAIN is incorrect.&amp;nbsp; There is no reason that X should remain 1 forever, once a single SCORE1 is passing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RW9 has posted a good approach.&amp;nbsp; I just wanted to make sure that your original question got answered.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 13:21:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295146#M61645</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-30T13:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295240#M61678</link>
      <description>&lt;P&gt;The ascii data file called grades.dat contains five exam scores (Score1, Score2, ..., Score5) for each of four students in a class. The first column contains the student id number (ID). The passing grade on each of the five exams was determined to be 65, 70, 60, 75, and 66, respectively. Your job is to read the ascii data into a temporary SAS data set called answers. Then, determine the number of exams passed by each student (Passed). In doing so: you should take advantage of arrays wherever possible you should take advantage of shortcut lists, such as numbered range lists, named range lists, or special name lists, wherever possible you should use temporary array elements wherever possible you should use iterative DO loops wherever possible When all is said and done, your answers data set should contain seven variables: ID (student id number), the five exam grades (Score1, Score2, ..., Score5), and the number of exams each student passed (Passed). Print the resulting answers data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;grades.dat datalines are :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;001 50 70 62 78 85&lt;BR /&gt;002 90 86 87 91 94&lt;BR /&gt;003 63 72 58 73 68&lt;BR /&gt;004 60 68 59 70 65&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 16:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295240#M61678</guid>
      <dc:creator>Saurav</dc:creator>
      <dc:date>2016-08-30T16:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295242#M61679</link>
      <description>Please revisit my question</description>
      <pubDate>Tue, 30 Aug 2016 16:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295242#M61679</guid>
      <dc:creator>Saurav</dc:creator>
      <dc:date>2016-08-30T16:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295245#M61681</link>
      <description>please revisit my question</description>
      <pubDate>Tue, 30 Aug 2016 16:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295245#M61681</guid>
      <dc:creator>Saurav</dc:creator>
      <dc:date>2016-08-30T16:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295246#M61682</link>
      <description>Incase i do not want to use SUM,? directly</description>
      <pubDate>Tue, 30 Aug 2016 16:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295246#M61682</guid>
      <dc:creator>Saurav</dc:creator>
      <dc:date>2016-08-30T16:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Please help in ARRAY problem</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295332#M61709</link>
      <description>&lt;P&gt;Maximizing use fo arrays and do loop per the instructions i get something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set score;
   array score(5) score1-score5;
   array passing (5) _temporary_ (65 70 60 75 66);
   array p (5) _temporary_;
   do i= 1 to dim(score);
      p[i] = (score[i] ge passing[i]);
   end;
   Passed = sum(of p(*));
   drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, all of those array definitions and calculations could be part of the data step that reads the data. Just put in the array and calculations after the INPUT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2016 21:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Please-help-in-ARRAY-problem/m-p/295332#M61709</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-08-30T21:20:05Z</dc:date>
    </item>
  </channel>
</rss>

