<?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 do I remove duplicates from a Proc Print Table after certain variables? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598722#M16348</link>
    <description>&lt;P&gt;You correctly identified my error (now fixed in the relevant post).&amp;nbsp; And yes, you suggesting of changing the spelling of _SENTINEL2 to SENTINEL2 will work.&amp;nbsp; But I'd recommend the opposite (change SENTINEL2 to _SENTINEL2).&amp;nbsp; That's because the statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; data need2 (drop=_sentinel:) / view=need2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will unnecessarily allow SENTINEL2 to remain in data set NEED2.&amp;nbsp; The "drop=_sentinel:" option removes all variables whose name begins with _SENTINEL (i.e. both _SENTINEL1 and _SENTINEL2).&amp;nbsp; I use the option it to eliminate no-longer-useful information in the desired data set.&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, 23 Oct 2019 14:28:27 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2019-10-23T14:28:27Z</dc:date>
    <item>
      <title>How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598248#M16269</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have a 9000 line data set (work.data) that displays loans and their associated values with them. One of the values: PERIOD_END_LSTAT tells me if the payments are overdue ("In Grace Period" or&amp;nbsp;"Late (31-120 days)" or&amp;nbsp;"Late (16-30 days)").&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the payments that occur more than once for the same loan, there are multiple rows of late payments (duplicates). As you can see in the screenshot, the observation 339 &amp;amp; 340 are the same, but I just want it to show up once.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below, I've sorted all of the late payments from the data set, but I just want to know how many unique loans have late payments:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Proc Print Data=work.data; 
where PERIOD_END_LSTAT = "In Grace Period" 
or PERIOD_END_LSTAT = "Late (31-120 days)" 
or PERIOD_END_LSTAT = "Late (16-30 days)";
Run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I remove the same loans that appear more than once? I just want it to show up once so I can count the unique loans.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 04:14:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598248#M16269</guid>
      <dc:creator>ChrisH10</dc:creator>
      <dc:date>2019-10-23T04:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598254#M16271</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296016"&gt;@ChrisH10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I have a 9000 line data set (work.data) that displays loans and their associated values with them. One of the values: PERIOD_END_LSTAT tells me if the payments are overdue ("In Grace Period" or&amp;nbsp;"Late (31-120 days)" or&amp;nbsp;"Late (16-30 days)").&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since the payments that occur more than once for the same loan, there are multiple rows of late payments (duplicates). As you can see in the screenshot, the observation 339 &amp;amp; 340 are the same, but I just want it to show up once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-10-21 at 12.58.38 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33332i49AF19D7E34DF5E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-10-21 at 12.58.38 PM.png" alt="Screen Shot 2019-10-21 at 12.58.38 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below, I've sorted all of the late payments from the data set, but I just want to know how many unique loans have late payments:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Proc Print Data=work.data; 
where PERIOD_END_LSTAT = "In Grace Period" 
or PERIOD_END_LSTAT = "Late (31-120 days)" 
or PERIOD_END_LSTAT = "Late (16-30 days)";
Run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I remove the same loans that appear more than once? I just want it to show up once so I can count the unique loans.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks! I'm very very new to SAS but need to learn this for a job offer.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which record do you want to display? First? Last? in the middle of a series? And if a load goes from "Late (16-30 days" to "Late (31-120 days)" what do you want to show in the output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may also have to provide the minimum list of variables needed to uniquely identify a "loan".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Likely you will need a data step to filter the records depending on your answers to the above questions.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 20:18:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598254#M16271</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-21T20:18:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598259#M16272</link>
      <description>&lt;P&gt;Well my main goal right now is to just make the table removed of all the duplicates where all of the columns are the same to the one above it (as in obs 339 and 340). I would want it to display all of the columns as shown in the screenshot. I mean the output would just need to be the removed duplicates table and a count of how many loans there are.&lt;BR /&gt;&lt;BR /&gt;The minimum list of variables I have decided to identify a loan are ID, IssuedDate and loan_amnt (not shown on screenshot):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;proc sort data=DATA out=SAS_Sorted_DATA nodupkey;

by id loan_amnt IssuedDate;

run;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Hopefully that helps!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 20:27:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598259#M16272</guid>
      <dc:creator>ChrisH10</dc:creator>
      <dc:date>2019-10-21T20:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598262#M16273</link>
      <description>&lt;P&gt;You apparently want to drop a line if it is a complete duplicate of the prior line.&amp;nbsp; If so, then make a temporary data set with the duplicates removed (data set view NEED2 below), and then PRINT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data need1 / view=need1;
  set have;
  retain _sentinel .;
run;
data need2 (drop=_sentinel:) /view=need2;
  set need1;
  by _all_;
  if first._sentinel;
run;

proc print data=need2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Data set NEED1 is nothing but your original dataset with new variable _SENTINEL set &lt;EM&gt;&lt;STRONG&gt;to the right of all the other variables&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data set NEED2 reads NEED1, using the BY _ALL_ NOTSORTED statement.&amp;nbsp; The consequence is that the "if first._sentinel" subsetting keeps only records &lt;EM&gt;&lt;STRONG&gt;in which _SENTINEL changes&amp;nbsp; or any variable to its left changes&lt;/STRONG&gt;&lt;/EM&gt;.&amp;nbsp; The result is a data set that you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 20:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598262#M16273</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-21T20:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598277#M16275</link>
      <description>&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So in your code, if the main data set is titled "work.data", would I be replacing the "have" in data need1 with "work.data"? or do I replace need1 with work.data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data need1 / view=need1;
  set &lt;U&gt;&lt;STRONG&gt;work.data&lt;/STRONG&gt;&lt;/U&gt;;
  retain _sentinel .;
run;

data need2 (drop=_sentinel:) /view=need2;
  set need1;
  by _all_;
  if first._sentinel;
run;

proc print data=need2;
run;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;or does it need to look like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data &lt;U&gt;&lt;STRONG&gt;work.data&lt;/STRONG&gt;&lt;/U&gt; / view=&lt;U&gt;&lt;STRONG&gt;work.data&lt;/STRONG&gt;&lt;/U&gt;;
  set have;
  retain _sentinel .;
run;

data need2 (drop=_sentinel:) /view=need2;
  set &lt;U&gt;&lt;STRONG&gt;work.data&lt;/STRONG&gt;&lt;/U&gt;;
  by _all_;
  if first._sentinel;
run;

proc print data=need2;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 Oct 2019 22:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598277#M16275</guid>
      <dc:creator>ChrisH10</dc:creator>
      <dc:date>2019-10-21T22:22:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598283#M16276</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296016"&gt;@ChrisH10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in your code, if the main data set is titled "work.data", would I be replacing the "have" in data need1 with "work.data"? or do I replace need1 with work.data?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a two-part answer:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Give it a try and see what happens.&lt;/LI&gt;
&lt;LI&gt;Yes, my dataset HAVE is an allegory for your WORK.DATA.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 21 Oct 2019 22:54:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598283#M16276</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-21T22:54:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598288#M16277</link>
      <description>&lt;P&gt;Great! Thanks for your help. I made a new data set called Work.Delinquentloans and used your code to narrow most of it down:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data WORK.DELINQUENTLOANS;
	set work.data;
	where PERIOD_END_LSTAT = "In Grace Period" 
	or PERIOD_END_LSTAT = "Late (31-120 days)" 
	or PERIOD_END_LSTAT = "Late (16-30 days)";
run;


data need1 / view=need1;
  set WORK.DELINQUENTLOANS;
  retain _sentinel .;
run;

data need2 (drop=_sentinel:) /view=need2;
  set need1;
  by _all_ notsorted;
  if first._sentinel;
run;

proc print data=need2;
run;&lt;/PRE&gt;&lt;P&gt;The last thing I realized running the new code is that there are a couple variables (INT_PAID, PRINCP_PAID and RECIEVED_AMT) that have values that need to be ignored for searching for duplicates. As you can see in Obs 3,4 &amp;amp; 5, it's the same loan but those specific variables are making it think it's three different loans. Any ideas on how to ignore some variables? Thanks again, it's much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-10-21 at 4.17.17 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33334iC8AB5337495EF73F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-10-21 at 4.17.17 PM.png" alt="Screen Shot 2019-10-21 at 4.17.17 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2019 23:21:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598288#M16277</guid>
      <dc:creator>ChrisH10</dc:creator>
      <dc:date>2019-10-21T23:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598428#M16288</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296016"&gt;@ChrisH10&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Great! Thanks for your help. I made a new data set called Work.Delinquentloans and used your code to narrow most of it down:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data WORK.DELINQUENTLOANS;
	set work.data;
	where PERIOD_END_LSTAT = "In Grace Period" 
	or PERIOD_END_LSTAT = "Late (31-120 days)" 
	or PERIOD_END_LSTAT = "Late (16-30 days)";
run;


data need1 / view=need1;
  set WORK.DELINQUENTLOANS;
  retain _sentinel .;
run;

data need2 (drop=_sentinel:) /view=need2;
  set need1;
  by _all_ notsorted;
  if first._sentinel;
run;

proc print data=need2;
run;&lt;/PRE&gt;
&lt;P&gt;The last thing I realized running the new code is that there are a couple variables (INT_PAID, PRINCP_PAID and RECIEVED_AMT) that have values that need to be ignored for searching for duplicates. As you can see in Obs 3,4 &amp;amp; 5, it's the same loan but those specific variables are making it think it's three different loans. Any ideas on how to ignore some variables? Thanks again, it's much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2019-10-21 at 4.17.17 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33334iC8AB5337495EF73F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-10-21 at 4.17.17 PM.png" alt="Screen Shot 2019-10-21 at 4.17.17 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Pick a specific list of variable names&amp;nbsp;that you do need to determine "loan". Replace the _all_ with that list in this data step.&lt;/P&gt;
&lt;PRE&gt;data need2 (drop=_sentinel:) /view=need2;
  set need1;
  by &lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;_all_&lt;/STRONG&gt;&lt;/FONT&gt; notsorted;
  if first._sentinel;
run;
&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Oct 2019 15:19:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598428#M16288</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-10-22T15:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598582#M16316</link>
      <description>&lt;P&gt;So you now are telling us that there are a few variables that you want to ignore when detecting duplicate records.&amp;nbsp; If there aren't too many variable to consider in the comparison of consecutive records, then list them in the DATA NEED2 step as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;suggests.&amp;nbsp; Or better yet, skip the DATA NEED2 step entirely and modify the DATA NEED1 step.&amp;nbsp; Let's say you only need to compare 4 varaibles (A,B,C and D).&amp;nbsp; Then you could:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.DELINQUENTLOANS;
	set work.data;
	where PERIOD_END_LSTAT = "In Grace Period" 
	or PERIOD_END_LSTAT = "Late (31-120 days)" 
	or PERIOD_END_LSTAT = "Late (16-30 days)";
run;


data need1 / view=need1;
  set WORK.DELINQUENTLOANS;
  by A B C D notsorted;
  if first.D;
run;


proc print data=need1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But if you have a lot of variables to compare, and only 3 to ignore (then I would keep the "BY _ALL_" but control what _ALL_ actually represents, as in&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.DELINQUENTLOANS;
	set work.data;
	where PERIOD_END_LSTAT = "In Grace Period" 
	or PERIOD_END_LSTAT = "Late (31-120 days)" 
	or PERIOD_END_LSTAT = "Late (16-30 days)";
run;


data need1 / view=need1;
  retain _sentinel1 .;
  if 0 then set work.delinquentloans (drop=INT_PAID, PRINCP_PAID RECIEVED_AMT);
  retain _sentinel2 .;
  set work.delinquentloans;
run;

 
data need2 (drop=_sentinel:) /view=need2;
  set need1;
  by _sentinel1--_sentinel2 notsorted;
  if first._sentinel2;
run;

proc print data=need2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What's different here?:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;DATA NEED1 has variables in this order, from left to right:
&lt;OL&gt;
&lt;LI&gt;_sentinel1&lt;/LI&gt;
&lt;LI&gt;all the original variables except INT_PAID, PRINCP_PAID and RECIEVED_AMT&lt;/LI&gt;
&lt;LI&gt;_sentinel2&lt;/LI&gt;
&lt;LI&gt;INT_PAID, PRINCP_PAID and RECIEVED_AMT&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;LI&gt;The reason DATA NEED1 has this is due the the "&lt;EM&gt;&lt;STRONG&gt;IF 0 then SET work.delinquentloans (drop=...)&lt;/STRONG&gt;&lt;/EM&gt;" which forces the SAS compiler to arrange the program-data-vector to make accommodations for&amp;nbsp;all the variables except INT_PAID, PRINCP_PAID and RECIEVED_AMT (because of the "drop=" option).&amp;nbsp;&amp;nbsp; But because it is "IF 0 THEN ..." the execution never happens.&amp;nbsp; Then the compiler encounters the RETAIN _SENTINEL2 statement.&amp;nbsp; Finally, the data is only actually read by the subsequent SET statement, where the 3 orphan variables are discovered by the compiler.&lt;/LI&gt;
&lt;LI&gt;The result is that the DATA NEED2 statement &lt;EM&gt;&lt;STRONG&gt;BY _SENTINEL1 -- _SENTINEL2&lt;/STRONG&gt;&lt;/EM&gt; tells SAS&amp;nbsp;to compare all the variables between _SENTINEL1 and _SENTINEL2 inclusive.
&lt;OL&gt;
&lt;LI&gt;Therefore the FIRST._SENTINEL2 dummy var tells you when _SENTINEL2 or any variable to its left has changed.&amp;nbsp; I.e. it ignores the variables to the right of _SENTINEL2 ((INT_PAID, PRINCP_PAID and RECIEVED_AMT).&lt;/LI&gt;
&lt;/OL&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Edit change:&amp;nbsp; corrected RETAIN SENTINEL2&amp;nbsp; to RETAIN _SENTINEL2.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 14:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598582#M16316</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-23T14:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598593#M16318</link>
      <description>&lt;P&gt;Thanks! I run into the error with the code (when trying your second piece of code), saying that:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ERROR: _sentinel2 does not follow _sentinel1 on the list of previously defined variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I'd assume I would change _sentinel2 to just sentinel2 right? to this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data need2 (drop=_sentinel:) /view=need2;
  set need1;
  by _sentinel1--sentinel2 notsorted;
  if first.sentinel2;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, if I attempt to run the above code, it just creates a NEED2 with no filtered data. What should I do to fix this?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Oct 2019 03:19:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598593#M16318</guid>
      <dc:creator>ChrisH10</dc:creator>
      <dc:date>2019-10-23T03:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do I remove duplicates from a Proc Print Table after certain variables?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598722#M16348</link>
      <description>&lt;P&gt;You correctly identified my error (now fixed in the relevant post).&amp;nbsp; And yes, you suggesting of changing the spelling of _SENTINEL2 to SENTINEL2 will work.&amp;nbsp; But I'd recommend the opposite (change SENTINEL2 to _SENTINEL2).&amp;nbsp; That's because the statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; data need2 (drop=_sentinel:) / view=need2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;will unnecessarily allow SENTINEL2 to remain in data set NEED2.&amp;nbsp; The "drop=_sentinel:" option removes all variables whose name begins with _SENTINEL (i.e. both _SENTINEL1 and _SENTINEL2).&amp;nbsp; I use the option it to eliminate no-longer-useful information in the desired data set.&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, 23 Oct 2019 14:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-remove-duplicates-from-a-Proc-Print-Table-after-certain/m-p/598722#M16348</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-23T14:28:27Z</dc:date>
    </item>
  </channel>
</rss>

