<?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: insert the last observation for every two or three observations in the main data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227776#M41071</link>
    <description>&lt;P&gt;Or&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST;
input X $ A B C;
cards;
A 1 2 3
B 4 5 6
C 7 8 9
D 1 2 6
E 3 7 9
Total 10 20 30
run;

data FINAL;
  set TEST nobs=NOBS ;
  if _N_ ne NOBS then output;
  if mod(_N_,2)=0 then do;
    set TEST point=NOBS ;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 29 Sep 2015 22:21:28 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2015-09-29T22:21:28Z</dc:date>
    <item>
      <title>insert the last observation for every two or three observations in the main data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227705#M41046</link>
      <description>&lt;P&gt;Hi, i have a data set like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input x$ a b c;&lt;BR /&gt;cards;&lt;BR /&gt;A 1 2 3&lt;BR /&gt;B 4 5 6&lt;BR /&gt;C 7 8 9&lt;BR /&gt;D 1 2 6&lt;BR /&gt;E 3 7 9&lt;BR /&gt;Total 10 20 30&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;I would like to create a data set like below. Which means i want to repeat the last row of my data set with every 2 &amp;nbsp;records of my existing data set. Please help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A 1 2 3&lt;BR /&gt;B 4 5 6&lt;BR /&gt;Total 10 20 30&lt;BR /&gt;C 7 8 9&lt;BR /&gt;D 1 2 6&lt;BR /&gt;Total 10 20 30&lt;BR /&gt;E 3 7 9&lt;BR /&gt;Total 10 20 30&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 16:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227705#M41046</guid>
      <dc:creator>sas715626</dc:creator>
      <dc:date>2015-09-29T16:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: insert the last observation for every two or three observations in the main data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227710#M41050</link>
      <description>&lt;P&gt;By just quick looking at your sample data, it makes little sense. Perhaps you could use more realistic names/values? And tell us why you wish to do this...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 16:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227710#M41050</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-09-29T16:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: insert the last observation for every two or three observations in the main data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227716#M41052</link>
      <description>&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;I have a real time scenario where if there are 100 rows and there will be a final row which is the sum of 100 rows , so total there will be 101 rows. I have to print 10 rows for each page + the sum row.The 11 th row is the sum of all 100 rows and nothing to do with the 10 rows. &amp;nbsp;So it will be like 11 rows for 10 pages. Hope it is clear. Please let em know if you need more information w.r.t this&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 17:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227716#M41052</guid>
      <dc:creator>sas715626</dc:creator>
      <dc:date>2015-09-29T17:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: insert the last observation for every two or three observations in the main data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227762#M41066</link>
      <description>&lt;P&gt;This should do the trick for you:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; x$ a b c;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;A 1 2 3&lt;/P&gt;
&lt;P&gt;B 4 5 6&lt;/P&gt;
&lt;P&gt;C 7 8 9&lt;/P&gt;
&lt;P&gt;D 1 2 6&lt;/P&gt;
&lt;P&gt;E 3 7 9&lt;/P&gt;
&lt;P&gt;Total 10 20 30&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; last;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; test &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=end;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; end &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; final(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=lastx lasta lastb lastc);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; test &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=end;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; _n_=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; last(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;rename&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;=(x=lastx a=lasta b=lastb c=lastc));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; mod(_n_,&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;)=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;x=lastx;&lt;/P&gt;
&lt;P&gt;a=lasta;&lt;/P&gt;
&lt;P&gt;b=lastb;&lt;/P&gt;
&lt;P&gt;c=lastc;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; not end &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 20:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227762#M41066</guid>
      <dc:creator>michelle_delaurentis_sas_com</dc:creator>
      <dc:date>2015-09-29T20:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: insert the last observation for every two or three observations in the main data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227776#M41071</link>
      <description>&lt;P&gt;Or&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST;
input X $ A B C;
cards;
A 1 2 3
B 4 5 6
C 7 8 9
D 1 2 6
E 3 7 9
Total 10 20 30
run;

data FINAL;
  set TEST nobs=NOBS ;
  if _N_ ne NOBS then output;
  if mod(_N_,2)=0 then do;
    set TEST point=NOBS ;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2015 22:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227776#M41071</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-09-29T22:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: insert the last observation for every two or three observations in the main data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227945#M41122</link>
      <description>&lt;P&gt;This sounds more like something for Proc Report than a data set issue. Data sets do not have pages but proc report has tools to break printed output at changes is the value of a grouping variable, to the sums (and other statistics) with in the group and then provide an overal summary at the end.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 21:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/insert-the-last-observation-for-every-two-or-three-observations/m-p/227945#M41122</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-09-30T21:11:11Z</dc:date>
    </item>
  </channel>
</rss>

