<?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 OUTPUT in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625062#M20195</link>
    <description>&lt;PRE&gt;DATA work(KEEP = i s1 s2 n);
ARRAY a(*) x1-x5;
DO i = 1 to DIM(a);
a(i) = i**2;
END;
s1 = sum(x1-x3);
s2 = SUM(of x1-x3);
n = _N_;
RUN; 
PROC PRINT DATA=work;
RUN;  &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;I have the code above. When I. put it in SAS and the result comes out like in the picture. Can anyone help me to understand this code and how it works please?&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-02-16 at 4.20.32 PM.png" style="width: 250px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36148i23F7D90FFD28AD09/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-02-16 at 4.20.32 PM.png" alt="Screen Shot 2020-02-16 at 4.20.32 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Feb 2020 03:23:03 GMT</pubDate>
    <dc:creator>kngu022</dc:creator>
    <dc:date>2020-02-16T03:23:03Z</dc:date>
    <item>
      <title>OUTPUT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625062#M20195</link>
      <description>&lt;PRE&gt;DATA work(KEEP = i s1 s2 n);
ARRAY a(*) x1-x5;
DO i = 1 to DIM(a);
a(i) = i**2;
END;
s1 = sum(x1-x3);
s2 = SUM(of x1-x3);
n = _N_;
RUN; 
PROC PRINT DATA=work;
RUN;  &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;I have the code above. When I. put it in SAS and the result comes out like in the picture. Can anyone help me to understand this code and how it works please?&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2020-02-16 at 4.20.32 PM.png" style="width: 250px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36148i23F7D90FFD28AD09/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2020-02-16 at 4.20.32 PM.png" alt="Screen Shot 2020-02-16 at 4.20.32 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 03:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625062#M20195</guid>
      <dc:creator>kngu022</dc:creator>
      <dc:date>2020-02-16T03:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: OUTPUT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625063#M20196</link>
      <description>&lt;P&gt;What do think it is doing?&amp;nbsp; What does each statement do?&amp;nbsp; There are only 9, counting the RUN.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 03:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625063#M20196</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-16T03:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: OUTPUT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625081#M20197</link>
      <description>&lt;P&gt;The code illustrates the difference of using x1-x3 as a formula (in the first sum() call) or as a list of variables (in the second sum() call) when the prefix "of" is used.&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 08:50:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625081#M20197</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-02-16T08:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: OUTPUT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625102#M20198</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/306646"&gt;@kngu022&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you execute the code step by step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;In a dataset named 'work' (also in the library named work ...) you initialize an array, which is a group of variables: the array name is a, it contains numeric variables x1, x2, x3, x4 and x5. As 5 variables have been referenced, the 'dimension' of the array is 5. You can now call 'x1' 'a(1)' and 'x2' 'a(2)', ... which is very practical in do loops. As these variables are new, the value is missing.&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ARRAY a(*) x1-x5;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.38.22.png" style="width: 130px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36153i122A943588DA8A11/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.38.22.png" alt="Capture d’écran 2020-02-16 à 10.38.22.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Then you use a do loop to compute the values of x1, x2, ... x5. The loop iterate from 1 to 5, which is the dimension of the array:
&lt;UL&gt;
&lt;LI&gt;i=1 -&amp;gt; a(1), which is x1 is equal to 1**2 so 1&lt;/LI&gt;
&lt;LI&gt;i=2 -&amp;gt; a(2), which is x2 is equal to 2**2 so 4&lt;/LI&gt;
&lt;LI&gt;...&lt;/LI&gt;
&lt;LI&gt;At the end i = 6&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DO i=1 to DIM(a);
	a(i)=i**2;
END;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture d’écran 2020-02-16 à 10.38.38.png" style="width: 153px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36154iAAFDAB0A8C305EA6/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.38.38.png" alt="Capture d’écran 2020-02-16 à 10.38.38.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Then you compute the sum of variables x1 minus x3 -&amp;gt; 1 &amp;nbsp;- 9 = -8.&amp;nbsp;This is completely different of the sum of variables x1, x2 and x3 -&amp;gt; 1 + 4 + 9 = 14. The keyword&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt; of&lt;/FONT&gt;&lt;/STRONG&gt; is very important here.&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;s1=sum(x1-x3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;s2=SUM(of x1-x3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.39.20.png" style="width: 190px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36156i0BACD504BE9FF1D5/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.39.20.png" alt="Capture d’écran 2020-02-16 à 10.39.20.png" /&gt;&lt;/span&gt;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;And then, you put in the variable 'n' the iteration number. Here, it is the first observation, so _n_ = 1.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.39.35.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36157i02480A915FFD8C00/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.39.35.png" alt="Capture d’écran 2020-02-16 à 10.39.35.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;n=_N_;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, you keep only the following variables in the data step (KEEP=i s1 s2 n) : i&amp;nbsp;s1 s2 n&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-16 à 10.39.57.png" style="width: 101px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36158i80B7E91A6709AC52/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture d’écran 2020-02-16 à 10.39.57.png" alt="Capture d’écran 2020-02-16 à 10.39.57.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 12:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625102#M20198</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-16T12:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: OUTPUT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625147#M20199</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;Thanks very much. Your direction is so so clear and easy to follow up.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Feb 2020 21:44:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625147#M20199</guid>
      <dc:creator>kngu022</dc:creator>
      <dc:date>2020-02-16T21:44:20Z</dc:date>
    </item>
    <item>
      <title>Re: OUTPUT</title>
      <link>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625199#M20208</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/306646"&gt;@kngu022&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're welcome!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 08:05:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/OUTPUT/m-p/625199#M20208</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-17T08:05:35Z</dc:date>
    </item>
  </channel>
</rss>

