<?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: SAS is duplicating observations when I split my dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469846#M120227</link>
    <description>&lt;P&gt;Use the macro from my footnote #2 to create a data step from your dataset. Then run that code and your split code in one sequence, and see what happens. If the effect is still there, copy/paste that &lt;U&gt;whole code&lt;/U&gt; into a code window here (see my footnote #3).&lt;/P&gt;
&lt;P&gt;Only then will all people here talk about the same thing, at the moment it's all guesswork because we really do not know the exact structure of your dataset and the exact code you ran. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s example &lt;U&gt;&lt;EM&gt;very clearly&lt;/EM&gt;&lt;/U&gt; shows that the code you initially posted works as desired, if the data looks &lt;EM&gt;like it seems&lt;/EM&gt; from your other post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This all once again illustrates why the "old hands" here are so adamant about posting example data in data steps. You would very probably have gotten a solution within two or three answers if you had presented your issue in the correct way.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jun 2018 07:38:57 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-06-13T07:38:57Z</dc:date>
    <item>
      <title>SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469774#M120206</link>
      <description>&lt;P&gt;I have a dataset and am trying to split it by the presence of a keyword in a variable string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data b c;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if find(school, "ELEMENTARY") then output b;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else output c;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting duplications in my dataset b (not all but a few observations are duplicating), none in dataset c. What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 21:55:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469774#M120206</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-06-12T21:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469775#M120207</link>
      <description>&lt;P&gt;perhaps you have values that are low case or mixed case as well?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if yes, to override that, can the following help at all?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data b c;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;set a;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if&lt;STRONG&gt;&lt;EM&gt; find(school, "ELEMENTARY",'i')&lt;/EM&gt;&lt;/STRONG&gt; then output b;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;else output c;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also, what do you mean by duplicates?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you post the sample data you are working with&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 22:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469775#M120207</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-06-12T22:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469779#M120210</link>
      <description>&lt;P&gt;I'm confused! Nothing in your code suggests that you're trying to eliminate duplicates. Since you didn't get any records in c, I would think that b would contain all of your records.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would help if you provided a sample dataset and, based on that sample, what you expect b and c to look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 22:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469779#M120210</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-06-12T22:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469786#M120213</link>
      <description>&lt;P&gt;I have already set to be all upper case before running the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data A;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&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; SCHOOL&lt;/P&gt;&lt;P&gt;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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELEMENTARY SCHOOL&lt;/P&gt;&lt;P&gt;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; MIDDLE SCHOOL&lt;/P&gt;&lt;P&gt;3&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; HIGH SCHOOL&lt;/P&gt;&lt;P&gt;4&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; DOVER ELEMENTARY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data B after split:&lt;/P&gt;&lt;P&gt;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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELEMENTARY SCHOOL&lt;/P&gt;&lt;P&gt;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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELEMENTARY SCHOOL&lt;/P&gt;&lt;P&gt;4&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; DOVER ELEMENTARY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data C after split:&lt;/P&gt;&lt;P&gt;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; MIDDLE SCHOOL&lt;/P&gt;&lt;P&gt;3&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; HIGH SCHOOL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 22:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469786#M120213</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-06-12T22:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469787#M120214</link>
      <description>&lt;P&gt;This should help clarify:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data A;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&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; SCHOOL&lt;/P&gt;&lt;P&gt;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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELEMENTARY SCHOOL&lt;/P&gt;&lt;P&gt;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; MIDDLE SCHOOL&lt;/P&gt;&lt;P&gt;3&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; HIGH SCHOOL&lt;/P&gt;&lt;P&gt;4&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; DOVER ELEMENTARY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data B after split:&lt;/P&gt;&lt;P&gt;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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELEMENTARY SCHOOL&lt;/P&gt;&lt;P&gt;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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELEMENTARY SCHOOL /*this was duplicated - occurred only once in A - dont want duplicate*/;&lt;/P&gt;&lt;P&gt;4&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; DOVER ELEMENTARY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sample data C after split:&lt;/P&gt;&lt;P&gt;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; MIDDLE SCHOOL&lt;/P&gt;&lt;P&gt;3&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; HIGH SCHOOL&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 22:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469787#M120214</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-06-12T22:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469791#M120216</link>
      <description>&lt;P&gt;That isn't what I get. I ran:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  informat SCHOOL $25.;
  input ID              SCHOOL &amp;amp;;
  cards;
1                    ELEMENTARY SCHOOL
2                    MIDDLE SCHOOL
3                    HIGH SCHOOL
4                    DOVER ELEMENTARY
;

data b c;
    set a;
    if find(school, "ELEMENTARY") then output b;
    else output c;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and got the expected two records in b and the other two in c.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 22:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469791#M120216</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-06-12T22:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469792#M120217</link>
      <description>&lt;P&gt;This is a sample dataset, I cannot post the actual dataset. As I mentioned, not all observations are duplicated&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 22:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469792#M120217</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-06-12T22:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469793#M120218</link>
      <description>&lt;P&gt;This step is NOT the source of the duplicates.&lt;/P&gt;
&lt;P&gt;Look at the code you used to create the input to this step.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 23:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469793#M120218</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-12T23:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469794#M120219</link>
      <description>&lt;P&gt;I run the duplicate check for data A right before this split and there are none, not sure what else it can be.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jun 2018 23:04:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469794#M120219</guid>
      <dc:creator>Melk</dc:creator>
      <dc:date>2018-06-12T23:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469796#M120220</link>
      <description>&lt;P&gt;Not sure what you mean by duplicate check.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only way code like what you posted could duplicate the ELEMENTARY records is if you have two OUTPUT statements being run.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data b c;
    set a;
    if find(school, "ELEMENTARY") then output b;
    if find(school, "ELEMENTARY") then output b;
    else output c;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or you forgot to tell it output only to C in the ELSE clause.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data b c;
    set a;
    if find(school, "ELEMENTARY") then output b;
    else output ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jun 2018 23:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469796#M120220</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-12T23:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469803#M120221</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; said, the code you posted cannot create duplicates.&amp;nbsp; It&amp;nbsp; reads each of the records in A, and outputs each record to B or C.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might add a duplicate check to your step.&amp;nbsp; For example, if SCHOOL is a unique ID, you can sort by SCHOOL, and then below IF statement will write an error to the log if there are any duplicate values in A.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a;
  by school;
run;

data b c;
    set a;
    by school ;
    if not (first.school and last.school) then putlog "ERROR: duplicate in A " school=; 

    if find(school, "ELEMENTARY") then output b;
    else output c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2018 00:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469803#M120221</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2018-06-13T00:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469846#M120227</link>
      <description>&lt;P&gt;Use the macro from my footnote #2 to create a data step from your dataset. Then run that code and your split code in one sequence, and see what happens. If the effect is still there, copy/paste that &lt;U&gt;whole code&lt;/U&gt; into a code window here (see my footnote #3).&lt;/P&gt;
&lt;P&gt;Only then will all people here talk about the same thing, at the moment it's all guesswork because we really do not know the exact structure of your dataset and the exact code you ran. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s example &lt;U&gt;&lt;EM&gt;very clearly&lt;/EM&gt;&lt;/U&gt; shows that the code you initially posted works as desired, if the data looks &lt;EM&gt;like it seems&lt;/EM&gt; from your other post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This all once again illustrates why the "old hands" here are so adamant about posting example data in data steps. You would very probably have gotten a solution within two or three answers if you had presented your issue in the correct way.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 07:38:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469846#M120227</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-13T07:38:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAS is duplicating observations when I split my dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469848#M120228</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/140721"&gt;@Melk&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;This is a sample dataset, I cannot post the actual dataset. As I mentioned, not all observations are duplicated&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why do you expect the doctor to give a correct diagnosis if you don't let her see the patient?&lt;/P&gt;
&lt;P&gt;Make up a sample dataset that makes the issue happen, and post it here. That it's not your code as initially posted has been proven already.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 07:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-is-duplicating-observations-when-I-split-my-dataset/m-p/469848#M120228</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-13T07:42:10Z</dc:date>
    </item>
  </channel>
</rss>

