<?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: Redundant retaining value ? in Programming 1 and 2</title>
    <link>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731804#M747</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original dataset is documented above, I quoted again here, sorry for a mess in the post.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Phil_NZ_0-1617770498901.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57031iD3AB555965B3921F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Phil_NZ_0-1617770498901.png" alt="Phil_NZ_0-1617770498901.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Apr 2021 04:41:52 GMT</pubDate>
    <dc:creator>Phil_NZ</dc:creator>
    <dc:date>2021-04-07T04:41:52Z</dc:date>
    <item>
      <title>Redundant retaining value ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731769#M745</link>
      <description>&lt;P&gt;Hi SAS instructors!&lt;/P&gt;
&lt;P&gt;Now I am in&amp;nbsp; lesson 7, practice, level 2&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Phil_NZ_1-1617756013302.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57021i5054D9CD0DE5A68D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Phil_NZ_1-1617756013302.png" alt="Phil_NZ_1-1617756013302.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In this practice, there is one thing I think redundant or maybe I fall into a fallacy.&lt;/P&gt;
&lt;P&gt;This is the requirement and the answer&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Phil_NZ_2-1617756109690.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57022iAB24D8A9D5C65C95/image-size/large?v=v2&amp;amp;px=999" role="button" title="Phil_NZ_2-1617756109690.png" alt="Phil_NZ_2-1617756109690.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The dataset&amp;nbsp; is as below:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ParkName	CampType	CampCount
Acadia NP	Tent	    152,811
Acadia NP	RV	        46,629
Acadia NP	Backcountry	1,324
Amistad NRA	Tent	    38
Amistad NRA	RV	        8,265&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I am wondering why you retain the ParkName here, because the table has been in narrow version so the ParkName will not be set as missing after each iteration.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data camping_wide (keep= parkname tent rv backcountry);
	set pg2.np_2016camping;
	by ParkName;
	retain Tent RV Backcountry;

	if camptype='Tent' then
		Tent=campcount;
	else if camptype='RV' then
		RV=campcount;
	else BACKCOUNTRY=campcount;
	format tent rv backcountry comma15.;

	if last.ParkName then
		output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I generate my code without retaining the ParkName and my result is similar to the one when applying your code&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Phil_NZ_0-1617755989554.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57020i0B52672B4C56F4A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Phil_NZ_0-1617755989554.png" alt="Phil_NZ_0-1617755989554.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I also present the debugger here for iteration 4 for clarifying purpose.&lt;/P&gt;
&lt;P&gt;If you retain the ParkName with any purpose that I did not notice, please let me know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm regards,&lt;/P&gt;
&lt;P&gt;Phil.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 00:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731769#M745</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-04-07T00:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: Redundant retaining value ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731785#M746</link>
      <description>&lt;P&gt;What is the order of the variables when you print the original data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 02:35:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731785#M746</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-04-07T02:35:36Z</dc:date>
    </item>
    <item>
      <title>Re: Redundant retaining value ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731804#M747</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The original dataset is documented above, I quoted again here, sorry for a mess in the post.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Phil_NZ_0-1617770498901.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/57031iD3AB555965B3921F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Phil_NZ_0-1617770498901.png" alt="Phil_NZ_0-1617770498901.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 04:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731804#M747</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-04-07T04:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: Redundant retaining value ?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731809#M748</link>
      <description>&lt;P&gt;Including PARKNAME in the RETAIN statement in the data step has no effect.&amp;nbsp; It does not harm, but it serves no purpose. &lt;EM&gt;Perhaps they did it just because they copied the KEEP statement?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they wanted the RETAIN statement to actual "retain" the variable PARKNAME that is not needed because PARKNAME must already be retained because it is coming from the input dataset.&amp;nbsp; If has to be in the input dataset or else the BY statement will generate an error.&amp;nbsp; Also note that in this simple data step the fact that PARKNAME is retained has no real effect because as soon as the SET statement executes the value retained is replaced with the value read from the input dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the wanted the RETAIN statement as a "trick" to insure the order of the variables without having to fully define the variables type and length then the retain statement would need to be before the SET statement (at least for the variables like PARKNAME that are coming from the input dataset.)&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 04:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/Redundant-retaining-value/m-p/731809#M748</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-07T04:53:40Z</dc:date>
    </item>
  </channel>
</rss>

