<?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 Append Dataset, Create Flag, and Remove Observations Based on Condition in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Append-Dataset-Create-Flag-and-Remove-Observations-Based-on/m-p/587656#M14721</link>
    <description>&lt;P&gt;How do I replicate the commands below in SAS?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the 1st line, the code appends a file and simultaneously generates a flag (validated)&amp;nbsp;where validated&amp;nbsp;= 1&amp;nbsp;and&amp;nbsp;not validated = 0. In the 2nd line, duplicate observations are identified and simultaneously generates a flag (dup) where both duplicates&amp;nbsp;= 1 and non-duplicates = 0.&amp;nbsp; In the 3rd line,&amp;nbsp;all duplicate observations that were contributed by the&amp;nbsp;master dataset are removed&amp;nbsp;(i.e. duplicate observations&amp;nbsp;contributed by&amp;nbsp;the append dataset are kept along with all non-duplicate observations&amp;nbsp;contributed&amp;nbsp;by&amp;nbsp;the&amp;nbsp;master dataset).&amp;nbsp; In the 4th line, the duplicate flag (dup) is removed from the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;append using "Not_Validated_Data", generate(validated)&lt;/P&gt;&lt;P&gt;duplicates tag&amp;nbsp;id date, generate(dup)&lt;/P&gt;&lt;P&gt;drop if dup ==1 &amp;amp; validated ==0&lt;/P&gt;&lt;P&gt;drop dup&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2019 19:44:47 GMT</pubDate>
    <dc:creator>mcanzater</dc:creator>
    <dc:date>2019-09-10T19:44:47Z</dc:date>
    <item>
      <title>Append Dataset, Create Flag, and Remove Observations Based on Condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Append-Dataset-Create-Flag-and-Remove-Observations-Based-on/m-p/587656#M14721</link>
      <description>&lt;P&gt;How do I replicate the commands below in SAS?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the 1st line, the code appends a file and simultaneously generates a flag (validated)&amp;nbsp;where validated&amp;nbsp;= 1&amp;nbsp;and&amp;nbsp;not validated = 0. In the 2nd line, duplicate observations are identified and simultaneously generates a flag (dup) where both duplicates&amp;nbsp;= 1 and non-duplicates = 0.&amp;nbsp; In the 3rd line,&amp;nbsp;all duplicate observations that were contributed by the&amp;nbsp;master dataset are removed&amp;nbsp;(i.e. duplicate observations&amp;nbsp;contributed by&amp;nbsp;the append dataset are kept along with all non-duplicate observations&amp;nbsp;contributed&amp;nbsp;by&amp;nbsp;the&amp;nbsp;master dataset).&amp;nbsp; In the 4th line, the duplicate flag (dup) is removed from the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;append using "Not_Validated_Data", generate(validated)&lt;/P&gt;&lt;P&gt;duplicates tag&amp;nbsp;id date, generate(dup)&lt;/P&gt;&lt;P&gt;drop if dup ==1 &amp;amp; validated ==0&lt;/P&gt;&lt;P&gt;drop dup&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2019 19:44:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Append-Dataset-Create-Flag-and-Remove-Observations-Based-on/m-p/587656#M14721</guid>
      <dc:creator>mcanzater</dc:creator>
      <dc:date>2019-09-10T19:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Append Dataset, Create Flag, and Remove Observations Based on Condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Append-Dataset-Create-Flag-and-Remove-Observations-Based-on/m-p/587708#M14729</link>
      <description>&lt;P&gt;It's been a while since I've used Stata, but I think this does it. A little verbose, but it works.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data validated;
	input id date $20.;
datalines;
1 1/1/2019
1 1/2/2019
1 3/4/2019
2 3/5/2019
2 4/5/2019
2 5/5/2019
2 6/7/2019
3 5/4/2019
;
run;

data not_validated;
	input id date $20.;
datalines;
1 3/5/2019
1 1/2/2019
1 3/4/2019
2 5/4/2019
2 4/5/2019
3 5/5/2019
3 5/4/2019
;
run;

data have;
	set validated (in=a)
		not_validated (in=b);
	if a and not b then validated = 1;
	else validated = 0;
run;

proc sort data=have;
	by id date;
run;

data want (drop=dup);
	set have2;
	by id date;
	if first.date then dup = 1;
	else dup = 0;
	if dup = 1 and validated = 0 then delete;
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>Wed, 11 Sep 2019 00:56:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Append-Dataset-Create-Flag-and-Remove-Observations-Based-on/m-p/587708#M14729</guid>
      <dc:creator>maguiremq</dc:creator>
      <dc:date>2019-09-11T00:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: Append Dataset, Create Flag, and Remove Observations Based on Condition</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Append-Dataset-Create-Flag-and-Remove-Observations-Based-on/m-p/590455#M15054</link>
      <description>&lt;P&gt;The solution provided me about 80% of what I was looking for; definitely put me on the right path.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 15:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Append-Dataset-Create-Flag-and-Remove-Observations-Based-on/m-p/590455#M15054</guid>
      <dc:creator>mcanzater</dc:creator>
      <dc:date>2019-09-20T15:50:40Z</dc:date>
    </item>
  </channel>
</rss>

