<?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: Use of return statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239580#M44096</link>
    <description>&lt;P&gt;Thanks Reeza, this example really helped understand return statment.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Dec 2015 17:33:45 GMT</pubDate>
    <dc:creator>SAS_inquisitive</dc:creator>
    <dc:date>2015-12-16T17:33:45Z</dc:date>
    <item>
      <title>Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239560#M44087</link>
      <description>&lt;P&gt;I looked at the pdv created by this program. When x=y it is returning to the top of the implicit loop of the data step without outputing &amp;nbsp;ie. this is not written to the pdv. I wonder why is it showing up in the output data set?&lt;/P&gt;&lt;PRE&gt;data survey;
   put _all_;
   input x y;
   if x=y then return;
   put _all_;
   datalines;
21 25
20 20
7 17
;&lt;BR /&gt;&lt;BR /&gt;*** pdv *****;&lt;BR /&gt;x=. y=. _ERROR_=0 _N_=1&lt;BR /&gt;x=21 y=25 _ERROR_=0 _N_=1&lt;BR /&gt;x=. y=. _ERROR_=0 _N_=2&lt;BR /&gt;x=. y=. _ERROR_=0 _N_=3&lt;BR /&gt;x=7 y=17 _ERROR_=0 _N_=3&lt;BR /&gt;x=. y=. _ERROR_=0 _N_=4&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 16:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239560#M44087</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2015-12-16T16:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239564#M44088</link>
      <description>&lt;P&gt;Return statement will 'return' to the beginning of the data step &lt;STRONG&gt;AND output the PDV content.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Your code did not capture PDV at the right moment. Try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data survey;
	put _all_;
	input x y;
	put _all_;

	if x=y then
		return;

	/*   put _all_;*/
	datalines;
21 25
20 20
7 17
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2015 16:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239564#M44088</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-12-16T16:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239570#M44089</link>
      <description>&lt;P&gt;Haikuo, if is not affecting the output data set, then what is the purpose of the return statment? &amp;nbsp;I wonder if there is an example with obvious effect of return statement. &amp;nbsp;Thanks !&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239570#M44089</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2015-12-16T17:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239574#M44091</link>
      <description>&lt;P&gt;It truncates the data step so nothing after the return is executed. This could be accomplished with if/then but can make processing faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
set sashelp.class;

if age=13 then return;

weight=0;

run;

proc print data=class;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:11:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239574#M44091</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-16T17:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239576#M44093</link>
      <description>&lt;P&gt;You were actually seeing the effect of 'return' statement without knowing it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if x=y then
		return;

	 put _all_;
	datalines;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In your original code, when 'return' happens (x=y),&amp;nbsp; the 'put _all_;' is NOT executed, that is why in your log you did not see the PDV content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:16:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239576#M44093</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2015-12-16T17:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239577#M44094</link>
      <description>&lt;P&gt;There's a different statement that does what you describe:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if x=y then delete;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By having both available, you get your choice of which tool to use.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239577#M44094</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-16T17:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239580#M44096</link>
      <description>&lt;P&gt;Thanks Reeza, this example really helped understand return statment.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239580#M44096</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2015-12-16T17:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239581#M44097</link>
      <description>&lt;P&gt;You'll get what you expected by taking control of the output process, i.e. by making the output operation explicit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data survey2;
	put _all_;
	input x y;
	put _all_;
	if x=y then return;
        output;
	datalines;
21 25
20 20
7 17
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239581#M44097</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-12-16T17:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239582#M44098</link>
      <description>&lt;P&gt;Thanks, Haikuo.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239582#M44098</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2015-12-16T17:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239583#M44099</link>
      <description>&lt;P&gt;There are two code branching statements available in the data step, GO TO and Link, that allow moving code that is executed conditionally out of the main program flow. The Return statement is then used to return to&amp;nbsp;the line after the&amp;nbsp;Link or Go To. These branches can be very helpful if you have&amp;nbsp;a longish bit of code that is only executed for a few records so that the main flow of the datastep is easier to follow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other program languages have different mechanisms such as BASIC's GOSUB or&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239583#M44099</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-12-16T17:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239584#M44100</link>
      <description>&lt;P&gt;I think this was what I want to see as the effect of return statment.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239584#M44100</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2015-12-16T17:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239585#M44101</link>
      <description>&lt;P&gt;Thanks, ballardw.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Dec 2015 17:55:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239585#M44101</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2015-12-16T17:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Use of return statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239739#M44154</link>
      <description>&lt;P&gt;Return does go back to the first line after the GOTO. &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;33         data _null_;
34            goto a;
35            put 'Did I return?';
36            stop;
37          a: put 'Did I goto?';
38            return;
39            run;

Did I goto?
NOTE: DATA statement used (Total process time):
      real time           0.18 seconds
      cpu time            0.01 seconds
      

40         
41         data _null_;
42            link a;
43            put 'Did I return?';
44            stop;
45          a: put 'Did I link?';
46            return;
47            run;

Did I link?
Did I return?&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Dec 2015 11:58:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-of-return-statement/m-p/239739#M44154</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-12-17T11:58:09Z</dc:date>
    </item>
  </channel>
</rss>

