<?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: Arrays in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257533#M268941</link>
    <description>&lt;P&gt;Having the data transposed from wide to long, makes it much easier to do this kind of counting (simple count() in SQL).&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2016 09:06:57 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-03-18T09:06:57Z</dc:date>
    <item>
      <title>Arrays in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257531#M268940</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data set which looks as&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ID Test_1 Test_2 Test_3 Test_4 Test_5&lt;BR /&gt;SH101 90 88 92 95 90&lt;BR /&gt;SH102 64 64 77 72 71&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Trying to count the number of tests passed by each student using temporary sas array values initialized as&amp;nbsp;(65,70,60,62,68).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA new;&lt;BR /&gt;SET Test_scores;&lt;BR /&gt;array test(5) Test_1 -- Test_5;&lt;BR /&gt;ARRAY num[5] _TEMPORARY_ (65,70,60,62,68);&lt;BR /&gt;do i=1 to dim(num);&lt;BR /&gt;if Test(i) &amp;lt; num(i) then flag="RA";&lt;BR /&gt;drop i;&lt;BR /&gt;end;&lt;BR /&gt;Run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Request you to help me with the codes. I would like to check across columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kafeel&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 08:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257531#M268940</guid>
      <dc:creator>KafeelBasha</dc:creator>
      <dc:date>2016-03-18T08:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257533#M268941</link>
      <description>&lt;P&gt;Having the data transposed from wide to long, makes it much easier to do this kind of counting (simple count() in SQL).&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 09:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257533#M268941</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-03-18T09:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257534#M268942</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH﻿&lt;/a&gt;&amp;nbsp;has said, normalising your data, so that it goes down the page is easier to work with - if you need transposed do it before the output step. &amp;nbsp;As for your array question the code:&lt;/P&gt;
&lt;PRE&gt;data have;
  input id $ test_1 test_2 test_3 test_4 test_5;
datalines;
SH101 90 88 92 95 90
SH102 64 64 77 72 71
;
run;

data want (drop=i);
  set have;
  array test_{5};
  array num{5} _temporary_ (65,70,60,62,68);
  do i=1 to 5;
    if test_{i} &amp;lt; num{i} then flag="RA";
  end;
run;&lt;/PRE&gt;
&lt;P&gt;Works fine per the logic given, what is the problem? &amp;nbsp;Also note the use of consistent case in the code, consitent indentations etc. &amp;nbsp;You can use the {i} above the post window to enter a code window.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2016 09:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257534#M268942</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-03-18T09:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257548#M268943</link>
      <description>&lt;P&gt;Hello Kafeel,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To count the number of tests passed by each student you could insert two lines of code into your program:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After the IF statement:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;else num_passed+1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;This sum statement implies a RETAIN for variable NUM_PASSED. Therefore, the counter has to be reset&amp;nbsp;before the DO statement:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;num_passed=0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Mar 2016 10:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257548#M268943</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-03-18T10:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Arrays in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257757#M268944</link>
      <description>&lt;P&gt;Since you want count the number , why you make a character variable FLAG?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;DATA new;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SET Test_scores;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;array test(5) Test_1 -- Test_5;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ARRAY num[5] _TEMPORARY_ (65,70,60,62,68);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;pass=0;&lt;BR /&gt;&lt;SPAN&gt;do i=1 to dim(num);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if Test(i) &amp;gt;= num(i) then pass+1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;drop i;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Run;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 19 Mar 2016 11:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Arrays-in-SAS/m-p/257757#M268944</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-03-19T11:05:51Z</dc:date>
    </item>
  </channel>
</rss>

