<?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 statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/OUTPUT-statement/m-p/665933#M199183</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The result of code1 and code2 are same. However, when I use the output statement before "end" the result is different in code3. I am trying to understand the logic of how this works when I have the "end" before and after the output statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*Code1*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;output;&lt;BR /&gt;if sex="M" then Sex1 = 1;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*Code1*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;output;&lt;BR /&gt;if sex="M" then do;&lt;BR /&gt;Sex1 = 1;&lt;BR /&gt;Sex2="Male";&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*Code3*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;output;&lt;BR /&gt;if sex="M" then do;&lt;BR /&gt;Sex1 = 1;&lt;BR /&gt;Sex2="Male";&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jun 2020 21:56:38 GMT</pubDate>
    <dc:creator>Tommer</dc:creator>
    <dc:date>2020-06-29T21:56:38Z</dc:date>
    <item>
      <title>OUTPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OUTPUT-statement/m-p/665933#M199183</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The result of code1 and code2 are same. However, when I use the output statement before "end" the result is different in code3. I am trying to understand the logic of how this works when I have the "end" before and after the output statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*Code1*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;output;&lt;BR /&gt;if sex="M" then Sex1 = 1;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*Code1*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;output;&lt;BR /&gt;if sex="M" then do;&lt;BR /&gt;Sex1 = 1;&lt;BR /&gt;Sex2="Male";&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;/*Code3*/&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data class;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;output;&lt;BR /&gt;if sex="M" then do;&lt;BR /&gt;Sex1 = 1;&lt;BR /&gt;Sex2="Male";&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 21:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OUTPUT-statement/m-p/665933#M199183</guid>
      <dc:creator>Tommer</dc:creator>
      <dc:date>2020-06-29T21:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: OUTPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OUTPUT-statement/m-p/665936#M199186</link>
      <description>&lt;P&gt;Code 3 does the second output step only when sex="M"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code 2 always does the second output step, whether sex="M" or not, because the output statement is not inside the IF-THEN DO-END&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 22:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OUTPUT-statement/m-p/665936#M199186</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-29T22:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: OUTPUT statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/OUTPUT-statement/m-p/665939#M199188</link>
      <description>&lt;P&gt;Indenting code consistently and with reasonable rules can often help resolve such timing issue questions. And pasting code or log entries into a code box opened on the forum with the &amp;lt;/&amp;gt; will preserve that indenting while the main message windows will remove characters.&lt;/P&gt;
&lt;PRE&gt;/*Code1*/

data class;
   set sashelp.class;
   output;
   if sex="M" then Sex1 = 1;
   output;
run;

/*Code2*/

data class;
   set sashelp.class;
   output;
   if sex="M" then do;
      Sex1 = 1;
      Sex2="Male";
   end;
   output;
run;

/*Code3*/

data class;
   set sashelp.class;
   output;
   if sex="M" then do;
      Sex1 = 1;
      Sex2="Male";
      output;       &amp;lt;= Easy to see &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;'s comment about conditional output.
   end;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 23:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/OUTPUT-statement/m-p/665939#M199188</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-29T23:21:08Z</dc:date>
    </item>
  </channel>
</rss>

