<?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: How to create a SAS data set that contains only the last record of each object ? in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510235#M6498</link>
    <description>&lt;P&gt;Why do you have to accomplish it via one data step ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs;
input  x $ y;
cards;
A	1
B	2
. 	3
C	4
. 	5
;
run;
data want;
 length x $ 40;
 retain x;
 merge have(rename=(x=xx)) have(keep=x rename=(x=_x) firstobs=2) end=last;
 if not missing(xx) then x=xx;
 if not missing(_x) or last;
 drop xx _x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 04 Nov 2018 10:23:23 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-11-04T10:23:23Z</dc:date>
    <item>
      <title>How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510138#M6491</link>
      <description>&lt;P&gt;I would like to ask if there is an example&amp;nbsp;raw data :&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;And now the&amp;nbsp;goal is to output each Variable ( A,B,C) contains the last record, such as:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;How can I&amp;nbsp;compute the data steps to make the missing variable ( e.g. the empty space below "B" ) also followed by the previous "B" and treat them as the same observation? And also how to compare between Variables to make them output different variable names?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have do some research that we can create the two variables for identify (A,B,C) by something call Var1 and Var2, then it can read the raw data record for Var1 and other variables from the same record. However, I feel confused&amp;nbsp;with this method.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any ways to achieve the above mentioned goal? Thank you for your help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 11:32:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510138#M6491</guid>
      <dc:creator>Kitty28</dc:creator>
      <dc:date>2018-11-03T11:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510140#M6493</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs;
input  x $ y;
cards;
A	1
B	2
. 	3
C	4
. 	5
;
run;
data temp;
 set have;
 length xx $ 40;
 retain xx;
 if not missing(x) then xx=x;
drop x;
run;
data want;
 set temp;
 by xx notsorted;
 if last.xx;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Nov 2018 11:47:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510140#M6493</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-03T11:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510141#M6494</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs;
input  x $ y;
cards;
A	1
B	2
. 	3
C	4
. 	5
;
run;
data temp;
 set have;
 length xx $ 40;
 retain xx;
 if not missing(x) then xx=x;
drop x;
run;
data want;
 set temp;
 by xx notsorted;
 if last.xx;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Nov 2018 11:49:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510141#M6494</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-03T11:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510142#M6495</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs;
input var1 $ var2;
cards;
A	1
B	2
. 	3
C	4
.	5
;

data have2;
	 set have;
	 retain holder;
	 if not missing(var1) then holder=var1;
run;
data want(drop=holder);
	 set have2;
	 by holder notsorted;
	 if last.holder;
	 var1=holder;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 12:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510142#M6495</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-03T12:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510188#M6496</link>
      <description>&lt;P&gt;Sorry, I may need to say that the goal have to be achieved within ONE data set step..... This is the restriction for this question.&lt;/P&gt;&lt;P&gt;Thank you for your help .&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 17:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510188#M6496</guid>
      <dc:creator>Kitty28</dc:creator>
      <dc:date>2018-11-03T17:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510190#M6497</link>
      <description>&lt;P&gt;You should have noted those requirements.&amp;nbsp; If you were the manager of a shop you would be calling someone back to work or having them redo their work because of poorly defined request.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img id="robotmad" class="emoticon emoticon-robotmad" src="https://communities.sas.com/i/smilies/16x16_robot-mad.png" alt="Robot Mad" title="Robot Mad" /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Nov 2018 17:39:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510190#M6497</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-03T17:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510235#M6498</link>
      <description>&lt;P&gt;Why do you have to accomplish it via one data step ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile cards expandtabs;
input  x $ y;
cards;
A	1
B	2
. 	3
C	4
. 	5
;
run;
data want;
 length x $ 40;
 retain x;
 merge have(rename=(x=xx)) have(keep=x rename=(x=_x) firstobs=2) end=last;
 if not missing(xx) then x=xx;
 if not missing(_x) or last;
 drop xx _x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Nov 2018 10:23:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510235#M6498</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-11-04T10:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510258#M6499</link>
      <description>Thanks for your help. As I am doing some testing with my friends, so as to make some changes to it.&lt;BR /&gt;Anyway the question is well-solved !</description>
      <pubDate>Sun, 04 Nov 2018 18:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510258#M6499</guid>
      <dc:creator>Kitty28</dc:creator>
      <dc:date>2018-11-04T18:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a SAS data set that contains only the last record of each object ?</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510260#M6500</link>
      <description>&lt;P&gt;If your question has been solved then you and your classmates should mark the those answers as approved solutions for the answer that solved your original question.&amp;nbsp; That would give credit to the individual that solved your question and&amp;nbsp;it closes unanswered question in the SAS communities Q.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Nov 2018 18:09:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-create-a-SAS-data-set-that-contains-only-the-last-record/m-p/510260#M6500</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-04T18:09:22Z</dc:date>
    </item>
  </channel>
</rss>

