<?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: Help to understand code in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244808#M17420</link>
    <description>&lt;P&gt;Some contributing factors:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Since the DATA step contains an OUTPUT statement, you will only output an observation when an OUTPUT statement executes.&lt;/LI&gt;
&lt;LI&gt;All OUTPUT statements depend on having STOP_IND=0&lt;/LI&gt;
&lt;LI&gt;For this particular set of 3 observations, the 1st observation will output and then set STOP_IND=1&lt;/LI&gt;
&lt;LI&gt;For the 2nd and 2rd observations, STOP_IND=1, so nothing gets output&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I hope this is enough ... there's really no substitute for understanding what the statements do.&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jan 2016 20:14:05 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-01-20T20:14:05Z</dc:date>
    <item>
      <title>Help to understand code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244800#M17418</link>
      <description>&lt;P&gt;Hello friends, please help me to understand this code, this is not my code, its existing code&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am testing code where one dataset "&lt;STRONG&gt;test&lt;/STRONG&gt;" resolving with 3 observation&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;file_name&amp;nbsp;&lt;/P&gt;
&lt;P&gt;20Jan16 &amp;nbsp; &amp;nbsp; test_file_20160120.txt&lt;/P&gt;
&lt;P&gt;19Jan16 &amp;nbsp; &amp;nbsp; test_file_20160119.txt&lt;/P&gt;
&lt;P&gt;18Jan16 &amp;nbsp; &amp;nbsp; test_file_20160118.txt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now after this dataset (test) created, below code is running and its giving only 1 observation, i really don't know why it is resolving to one but i am expecting it should has 3 observation&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;%macro test (x_date);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;%let store_x_date="null";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;data test_2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt; retain stop_ind;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; if _N_ = 1 then stop_ind = 0;&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#0000FF"&gt; set test;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; by DESCENDING DATE;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; if last.DATE = 1 then do;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; if stop_ind = 0 then do;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; output;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; Author_DATE = put(DATE, date.);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; call symput("&amp;amp;x_date.",Author_DATE);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; stop_ind = 1;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; if stop_ind = 0 then output;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt; run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;%mend;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;%test (&lt;SPAN&gt;store_x_date);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 19:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244800#M17418</guid>
      <dc:creator>woo</dc:creator>
      <dc:date>2016-01-20T19:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help to understand code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244806#M17419</link>
      <description>&lt;P&gt;This is where formatting your code helps. &amp;nbsp;Note that there's an output statement nested in an IF condition and a second one in the last statement. The goal seems to be to create a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test (x_date);

%let store_x_date="null";

  data test_2;
  retain stop_ind;
  
  if _N_ = 1 then stop_ind = 0;

  set test;
  by DESCENDING DATE;

  if last.DATE = 1 then do;
        if stop_ind = 0 then do;
              output;
              Author_DATE = put(DATE, date.);
              call symput("&amp;amp;x_date.",Author_DATE);
        end;
   stop_ind = 1;
   end;

   if stop_ind = 0 then output;
   run;
%mend;

%test (store_x_date);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244806#M17419</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-20T20:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help to understand code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244808#M17420</link>
      <description>&lt;P&gt;Some contributing factors:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Since the DATA step contains an OUTPUT statement, you will only output an observation when an OUTPUT statement executes.&lt;/LI&gt;
&lt;LI&gt;All OUTPUT statements depend on having STOP_IND=0&lt;/LI&gt;
&lt;LI&gt;For this particular set of 3 observations, the 1st observation will output and then set STOP_IND=1&lt;/LI&gt;
&lt;LI&gt;For the 2nd and 2rd observations, STOP_IND=1, so nothing gets output&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I hope this is enough ... there's really no substitute for understanding what the statements do.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 20:14:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244808#M17420</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-01-20T20:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help to understand code</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244817#M17422</link>
      <description>&lt;P&gt;Thanks a lot Astouning and Reeza, appreciate your input,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jan 2016 21:00:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Help-to-understand-code/m-p/244817#M17422</guid>
      <dc:creator>woo</dc:creator>
      <dc:date>2016-01-20T21:00:37Z</dc:date>
    </item>
  </channel>
</rss>

