<?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 How comes first.ParkName = 1 and ParkName. col = 1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-comes-first-ParkName-1-and-ParkName-col-1/m-p/648428#M194227</link>
    <description>&lt;PRE&gt;proc sort data=pg2.np_acres 
          out=sortedAcres(keep=Region ParkName State GrossAcres);
    by Region ParkName;
run;
	
data multiState singleState;
    set sortedAcres;
    by Region ParkName;
    if First.ParkName=1 and Last.ParkName=1 
        then output singleState;
    else output multiState;
    format GrossAcres comma15.;
run;&lt;/PRE&gt;</description>
    <pubDate>Sun, 17 May 2020 19:47:44 GMT</pubDate>
    <dc:creator>AMIN_ALJALLAD</dc:creator>
    <dc:date>2020-05-17T19:47:44Z</dc:date>
    <item>
      <title>How comes first.ParkName = 1 and ParkName. col = 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-comes-first-ParkName-1-and-ParkName-col-1/m-p/648428#M194227</link>
      <description>&lt;PRE&gt;proc sort data=pg2.np_acres 
          out=sortedAcres(keep=Region ParkName State GrossAcres);
    by Region ParkName;
run;
	
data multiState singleState;
    set sortedAcres;
    by Region ParkName;
    if First.ParkName=1 and Last.ParkName=1 
        then output singleState;
    else output multiState;
    format GrossAcres comma15.;
run;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 May 2020 19:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-comes-first-ParkName-1-and-ParkName-col-1/m-p/648428#M194227</guid>
      <dc:creator>AMIN_ALJALLAD</dc:creator>
      <dc:date>2020-05-17T19:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: How comes first.ParkName = 1 and ParkName. col = 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-comes-first-ParkName-1-and-ParkName-col-1/m-p/648432#M194231</link>
      <description>&lt;P&gt;&lt;CODE&gt;last.&amp;lt;variable&amp;gt;&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(and corresponding&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;first.&amp;lt;variable&amp;gt;&lt;/CODE&gt;) are two automatic temporary variables created for each&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;BY&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;variable and indicate if the current row is at a group edge row; either the first or last row of a by-group level.&lt;/P&gt;
&lt;P&gt;You can infer information about where the current observation is within the group&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;FIRST.  LAST.   where
  1             at first in group
  0             not at first in group
          1     at last in group
          0     not at last in group
  1       0     group has &amp;gt;= 2 rows and currently at first in group
  0       0     group has &amp;gt;= 3 rows and currently in the middle part
  0       1     group has &amp;gt;= 2 rows and currently at last in group
  1       1     group has only 1 row
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Learning about the underlying premises of the implicit loop fundamental to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;DATA/SET&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;processing will make you a better SAS coder:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;A good starter is SUGI 30 paper&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi30/134-30.pdf" rel="nofollow noreferrer" target="_blank"&gt;"A Hands-On Introduction to SAS® DATA Step Programming"&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Debbie Buck, D. B. &amp;amp; P. Associates, Houston, TX".&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Ian Whitlock's papers are some of the best. Try his SUGI 31&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings/proceedings/sugi31/246-31.pdf" rel="nofollow noreferrer" target="_blank"&gt;"How to Think Through the SAS® DATA Step "&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Sun, 17 May 2020 20:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-comes-first-ParkName-1-and-ParkName-col-1/m-p/648432#M194231</guid>
      <dc:creator>RichardDeVen</dc:creator>
      <dc:date>2020-05-17T20:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: How comes first.ParkName = 1 and ParkName. col = 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-comes-first-ParkName-1-and-ParkName-col-1/m-p/648433#M194232</link>
      <description>&lt;P&gt;Thank you for your contribution.&lt;/P&gt;&lt;P&gt;My concern at first is how the both is set to 1 at the same time. However, I discovered that when the value id unique, then first and last variable will be 1&lt;/P&gt;</description>
      <pubDate>Sun, 17 May 2020 20:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-comes-first-ParkName-1-and-ParkName-col-1/m-p/648433#M194232</guid>
      <dc:creator>AMIN_ALJALLAD</dc:creator>
      <dc:date>2020-05-17T20:17:03Z</dc:date>
    </item>
  </channel>
</rss>

