<?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: Splitting a SAS dataset into 2 sets based on specific IDs. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912546#M359731</link>
    <description>&lt;P&gt;Let's suppose ID number 1234 and ID 5678 belongs in one data table, and the rest belong in another table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data part1 part2;
    set table1;
    if id=1234 or id=5678 then output part1;
    else output part2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea of splitting this large table up this way has advantages and disadvantages. Most of the time (in my opinion) it is better to leave the table as one large table and use WHERE statements or BY statement to pick the parts you want for any particular analysis. But the answer also depends on what you plan to do with this data, what are the next steps, how will it be used — context is important and you have given us no context at all.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2024 20:29:26 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-01-22T20:29:26Z</dc:date>
    <item>
      <title>Splitting a SAS dataset into 2 sets based on specific IDs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912545#M359730</link>
      <description>&lt;P&gt;I am very new to SAS programming, and I'm working with a large dataset (Table1) that I need to split based on specific IDs, with one set containing about 70 IDs (Table2) (some with more than one row of data per ID), and the other with a few 100K.&amp;nbsp; I was able to create the smaller table (Table2) with the 70 ID's, but the original set (Table1) still contains those IDs. How can I either create a new table that excludes those IDs or remove them from Table1 so they aren't duplicated when comparing the two sets?&amp;nbsp; I put the code below that I used to subset the smaller table with the specific IDs. I am just nor sure how to proceed. Thanks for helping the newbie!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(Subset data into new table with specific IDs)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort&lt;/STRONG&gt; &lt;FONT color="#3366FF"&gt;data&lt;/FONT&gt;=Table1;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;by&lt;/FONT&gt; ID;&lt;BR /&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&amp;nbsp;Table2;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;set &lt;/FONT&gt;Table1;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;where&lt;/FONT&gt; ID in (01, 02, 03, 04, etc...)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 20:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912545#M359730</guid>
      <dc:creator>BW18</dc:creator>
      <dc:date>2024-01-22T20:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a SAS dataset into 2 sets based on specific IDs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912546#M359731</link>
      <description>&lt;P&gt;Let's suppose ID number 1234 and ID 5678 belongs in one data table, and the rest belong in another table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data part1 part2;
    set table1;
    if id=1234 or id=5678 then output part1;
    else output part2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The idea of splitting this large table up this way has advantages and disadvantages. Most of the time (in my opinion) it is better to leave the table as one large table and use WHERE statements or BY statement to pick the parts you want for any particular analysis. But the answer also depends on what you plan to do with this data, what are the next steps, how will it be used — context is important and you have given us no context at all.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 20:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912546#M359731</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-22T20:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a SAS dataset into 2 sets based on specific IDs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912547#M359732</link>
      <description>&lt;P&gt;Your second step creates a new data set Table2 but only reads data from Table1, it does not modify it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can "overwrite" Table1, or better create Table3, with no selected IDs in the following way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table2 Table3;
  set Table1;
  IF ID in (01, 02, 03, 04, etc...) 
    THEN output Table2;
    ELSE output Table3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 20:19:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912547#M359732</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-01-22T20:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting a SAS dataset into 2 sets based on specific IDs.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912555#M359733</link>
      <description>Thank you so much! The If-Then-Else statement worked beautifully. I thought this might be what I needed, but I was not sure how to handle the "If" statement and whether or not each ID would have to be listed as an individual statement. Thank you for clarifying this!</description>
      <pubDate>Mon, 22 Jan 2024 20:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-a-SAS-dataset-into-2-sets-based-on-specific-IDs/m-p/912555#M359733</guid>
      <dc:creator>BW18</dc:creator>
      <dc:date>2024-01-22T20:51:36Z</dc:date>
    </item>
  </channel>
</rss>

