<?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: Last.X and First.X on the same time in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/438000#M109166</link>
    <description>&lt;P&gt;No probs, it likely not be the first or last tough day!&lt;/P&gt;</description>
    <pubDate>Fri, 16 Feb 2018 15:27:52 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-02-16T15:27:52Z</dc:date>
    <item>
      <title>Last.X and First.X on the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437993#M109162</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance a dataset is sorted by variable X.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How in one iteration reveal if an observation is only one in a group:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if first.X and last.X ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 15:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437993#M109162</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2018-02-16T15:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: Last.X and First.X on the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437994#M109163</link>
      <description>&lt;P&gt;Thats it you have it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  by x;
  if first.x and last.x then only_one="Yes";
  else only_one="No";
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Feb 2018 15:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437994#M109163</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-16T15:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Last.X and First.X on the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437998#M109164</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you sort a data set&amp;nbsp; and in a data step when you specify by variable then sas creates two automatic variables back end they are first.by variable and last.by variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;first.by variable value is=1 for the first observation in a dataset and rest of all the by group will be =0 except last.by variable. that will be one&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can observe it by writing example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=ds;&lt;BR /&gt;by sex;&lt;BR /&gt;run;&lt;BR /&gt;data ds;&lt;BR /&gt;set sashelp.classfit;&lt;BR /&gt;by sex;&lt;BR /&gt;put _all_;'&lt;/P&gt;&lt;P&gt;if first.sex and last.x then flag=1;&lt;/P&gt;&lt;P&gt;else flag=0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 15:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437998#M109164</guid>
      <dc:creator>srinath3111</dc:creator>
      <dc:date>2018-02-16T15:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Last.X and First.X on the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437999#M109165</link>
      <description>You are definitely right ). It was rather a "tough" day today (</description>
      <pubDate>Fri, 16 Feb 2018 15:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/437999#M109165</guid>
      <dc:creator>DmytroYermak</dc:creator>
      <dc:date>2018-02-16T15:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: Last.X and First.X on the same time</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/438000#M109166</link>
      <description>&lt;P&gt;No probs, it likely not be the first or last tough day!&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2018 15:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Last-X-and-First-X-on-the-same-time/m-p/438000#M109166</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-16T15:27:52Z</dc:date>
    </item>
  </channel>
</rss>

