<?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 row of a dataset in All Things Community</title>
    <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305615#M1952</link>
    <description>what does OR operator signifies in the statement then.If Last.variable1 OR Last.variable2</description>
    <pubDate>Wed, 19 Oct 2016 09:42:08 GMT</pubDate>
    <dc:creator>monalisa</dc:creator>
    <dc:date>2016-10-19T09:42:08Z</dc:date>
    <item>
      <title>last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305605#M1947</link>
      <description>&lt;P&gt;I have an existing SAS query&amp;nbsp;the last row of a dataset is fetched on below condition:&lt;/P&gt;&lt;P&gt;If Last.variable1 OR Last.variable2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one please help me in understanding the above condition?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 08:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305605#M1947</guid>
      <dc:creator>monalisa</dc:creator>
      <dc:date>2016-10-19T08:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305608#M1948</link>
      <description>&lt;P&gt;You have &lt;FONT face="courier new,courier"&gt;by&lt;/FONT&gt; statement in that &lt;FONT face="courier new,courier"&gt;data&lt;/FONT&gt; step that contains both variable1 and variable2.&lt;/P&gt;
&lt;P&gt;last.variable1 is an automatic boolean variable that is set to 1 when the next observation will have a different value for variable1 than the current observation, likewise for variable2&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 08:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305608#M1948</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-19T08:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305609#M1949</link>
      <description>&lt;P&gt;There are many topics out there on this subject including the SAS documentation. &amp;nbsp;last.&amp;lt;by group variable&amp;gt; is a flag assigned to the last observeration within each by group. &amp;nbsp;So imainge you by group this data:&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; B&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you say:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
&amp;nbsp; set have;&lt;BR /&gt;  by a b;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You data would look like this (note the additional variables are not stored in the output dataset only during processing):&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; lastflag&amp;lt;a&amp;gt; &amp;nbsp; lastflag&amp;lt;b&amp;gt;&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the flag is set on the last occurence of the variable within the by group. &amp;nbsp;So your logic:&lt;/P&gt;
&lt;P&gt;A &amp;nbsp; &amp;nbsp; B &amp;nbsp; &amp;nbsp; lastflag&amp;lt;a&amp;gt; &amp;nbsp; lastflag&amp;lt;b&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =true&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =true&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =true&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =false&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =true&lt;/P&gt;
&lt;P&gt;2 &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =true&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;
&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, 19 Oct 2016 08:55:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305609#M1949</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-19T08:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305610#M1950</link>
      <description>Thanks.&lt;BR /&gt;Yes the query has order by variable1 , variable2.&lt;BR /&gt;&lt;BR /&gt;Can you help me in understanding with one example&lt;BR /&gt;</description>
      <pubDate>Wed, 19 Oct 2016 08:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305610#M1950</guid>
      <dc:creator>monalisa</dc:creator>
      <dc:date>2016-10-19T08:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305612#M1951</link>
      <description>&lt;P&gt;This should illustrate the workings of the last. variables sufficiently:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input variable1 variable2;
cards;
1 1
1 1
1 2
1 3
2 3
2 4
3 1
;
run;

data want;
set have;
by variable1 variable2;
label
  x1='last.variable1'
  x2='last.variable2'
;
x1 = last.variable1;
x2 = last.variable2;
run;

proc print label;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;                                   last.        last.
Obs    variable1    variable2    variable1    variable2

 1         1            1            0            0    
 2         1            1            0            1    
 3         1            2            0            1    
 4         1            3            1            1    
 5         2            3            0            1    
 6         2            4            1            1    
 7         3            1            1            1    
&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Oct 2016 09:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305612#M1951</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-19T09:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305615#M1952</link>
      <description>what does OR operator signifies in the statement then.If Last.variable1 OR Last.variable2</description>
      <pubDate>Wed, 19 Oct 2016 09:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305615#M1952</guid>
      <dc:creator>monalisa</dc:creator>
      <dc:date>2016-10-19T09:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305618#M1953</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/101869"&gt;@monalisa&lt;/a&gt; wrote:&lt;BR /&gt;what does OR operator signifies in the statement then.If Last.variable1 OR Last.variable2&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You know what a logical or is? If not, I guess you are in a completely wrong place here.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 10:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305618#M1953</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-19T10:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305619#M1954</link>
      <description>&lt;P&gt;See logical boolean operation in the guidance:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://v8doc.sas.com/sashtml/lrcon/z0780367.htm" target="_blank"&gt;https://v8doc.sas.com/sashtml/lrcon/z0780367.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 10:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305619#M1954</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-10-19T10:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: last row of a dataset</title>
      <link>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305660#M1955</link>
      <description>&lt;P&gt;One of the implications of "OR" in this code is that the person who wrote the code is unsure of what they are doing.&amp;nbsp; Whoever wrote it may not be a good person to get help from in understanding the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the program uses this statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by variable1 variable2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One result is that this statement is redundant:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if last.variable1 or last.variable2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The observations selected by the condition "last.variable2" include all the observations that would be selected by "last.variable1".&amp;nbsp; The same results would be obtained by coding:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if last.variable2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;None of this is a substitute for reading the documentation and learning about BY variables.&amp;nbsp; But it is a fact of life that you can inherit code written programmers who have varying degrees of expertise.&amp;nbsp; One of the challenges is figuring out whether the author of the code made good choices when selecting programming tools.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2016 13:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/All-Things-Community/last-row-of-a-dataset/m-p/305660#M1955</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-19T13:29:59Z</dc:date>
    </item>
  </channel>
</rss>

