<?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 large dataset into smaller datasets while keeping observations for same ID together in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Splitting-large-dataset-into-smaller-datasets-while-keeping/m-p/524153#M142499</link>
    <description>&lt;P&gt;Sort by patient_id.&lt;/P&gt;
&lt;P&gt;Run this data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data intermediate;
set have end=eof;
by patient_id;
retain counter 0 ds_counter 1;
counter + 1;
if first.patient_id and counter ge 20000
then do;
  ds_counter + 1;
  counter = 1;
end;
if end then call symputx('num_ds',ds_counter);
drop counter;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You now have the maximum number of datasets in the macro variable (for use in a %do loop), and an indicator in every observation where it should go.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jan 2019 18:39:16 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-01-02T18:39:16Z</dc:date>
    <item>
      <title>Splitting large dataset into smaller datasets while keeping observations for same ID together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-large-dataset-into-smaller-datasets-while-keeping/m-p/524146#M142498</link>
      <description>&lt;P&gt;I have a large file of inpatient stays that I need to split into smaller files (approx. 20,000 observations) for operational purposes.&amp;nbsp; A patient (patient_id) may have one or more observations in the data set, these observations need to be kept together in the new smaller datasets, i.e., I can't split the large dataset into the first 20000 obs and then the second 20000 and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make sure to keep the observations for a particular patient (patient_ID) together?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 18:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-large-dataset-into-smaller-datasets-while-keeping/m-p/524146#M142498</guid>
      <dc:creator>akj</dc:creator>
      <dc:date>2019-01-02T18:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Splitting large dataset into smaller datasets while keeping observations for same ID together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Splitting-large-dataset-into-smaller-datasets-while-keeping/m-p/524153#M142499</link>
      <description>&lt;P&gt;Sort by patient_id.&lt;/P&gt;
&lt;P&gt;Run this data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data intermediate;
set have end=eof;
by patient_id;
retain counter 0 ds_counter 1;
counter + 1;
if first.patient_id and counter ge 20000
then do;
  ds_counter + 1;
  counter = 1;
end;
if end then call symputx('num_ds',ds_counter);
drop counter;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You now have the maximum number of datasets in the macro variable (for use in a %do loop), and an indicator in every observation where it should go.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jan 2019 18:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Splitting-large-dataset-into-smaller-datasets-while-keeping/m-p/524153#M142499</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-01-02T18:39:16Z</dc:date>
    </item>
  </channel>
</rss>

