<?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: create subsets of data: first contain the first 100 obs, second and third contain the second and third 100 obs of the original dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171303#M32892</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a link that explains the variety of ways.&lt;/P&gt;&lt;P&gt;Note the following though:&lt;/P&gt;&lt;H2&gt;&lt;SPAN class="mw-headline" id="Best_Practice:_Just_Don.27t_Do_It"&gt;Best Practice: Just Don't Do It&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;I'd bet there's a better way to do what you're doing especially if the subsets are sized at 100.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;EDIT: Here's the link &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;&lt;A href="http://www.sascommunity.org/wiki/Split_Data_into_Subsets" title="http://www.sascommunity.org/wiki/Split_Data_into_Subsets"&gt;Split Data into Subsets - sasCommunity&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Dec 2013 21:38:15 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-12-12T21:38:15Z</dc:date>
    <item>
      <title>create subsets of data: first contain the first 100 obs, second and third contain the second and third 100 obs of the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171298#M32887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;How can I create subsets of a dataset with macro or other methods that meet the requirment that the first subset contains the first 100 observations, and the second,third,fourth subsets contains the second,third and fourth 100 observations respectively. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 08:35:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171298#M32887</guid>
      <dc:creator>owenwqp1</dc:creator>
      <dc:date>2013-12-12T08:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: create subsets of data: first contain the first 100 obs, second and third contain the second and third 100 obs of the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171299#M32888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data sample1 sample2 sample3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if _n_&amp;lt;=100 then output sample1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if 100&amp;lt;_n_&amp;lt;=200 then output sample2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if 200&amp;lt;_n_&amp;lt;=300 then output sample3;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 08:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171299#M32888</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-12-12T08:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: create subsets of data: first contain the first 100 obs, second and third contain the second and third 100 obs of the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171300#M32889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your help. But I have create many subsets, more than 100. Can you tell me simpler solutions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 09:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171300#M32889</guid>
      <dc:creator>owenwqp1</dc:creator>
      <dc:date>2013-12-12T09:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: create subsets of data: first contain the first 100 obs, second and third contain the second and third 100 obs of the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171301#M32890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using sashelp.class and a split by 5:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let split=5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; call symputx('nobs',nobs);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; stop;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set sashelp.class nobs=nobs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro subset;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %let part=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %do i=1 %to &amp;amp;nobs %by &amp;amp;split;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let part=%eval(&amp;amp;part+1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data subset&amp;amp;part;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class(firstobs=&amp;amp;i obs=%eval(&amp;amp;i-1+&amp;amp;split));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend subset;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%subset;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 13:46:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171301#M32890</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2013-12-12T13:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: create subsets of data: first contain the first 100 obs, second and third contain the second and third 100 obs of the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171302#M32891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need either a macro like Amir demonstrates or you need to use a hash table as this allows you to create new output data sets during data step execution time. Below a hash approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;&amp;nbsp; do i=1 to 501;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var=ceil(ranuni(1)*1000);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;&amp;nbsp; stop;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data mapping;&lt;BR /&gt;&amp;nbsp; stop;&lt;BR /&gt;&amp;nbsp; length hash_key $1;&lt;BR /&gt;&amp;nbsp; call missing(hash_key);&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp; set have end=last;&lt;BR /&gt;&amp;nbsp; if _n_=1 then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 0 then set mapping;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; declare hash h (dataset:'mapping',multidata:'y');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h.defineKey('hash_key');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h.defineData(all:'y');&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h.defineDone();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; _iter+1;&lt;BR /&gt;&amp;nbsp; _rc=h.add();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if mod(_n_,100)=0 or last then &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h.output(dataset:cats('sample_ds_',_n_-_iter+1,'_to_',_n_,'(drop=hash_key)'));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _rc=h.clear();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _iter=0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 21:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171302#M32891</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-12-12T21:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: create subsets of data: first contain the first 100 obs, second and third contain the second and third 100 obs of the original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171303#M32892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's a link that explains the variety of ways.&lt;/P&gt;&lt;P&gt;Note the following though:&lt;/P&gt;&lt;H2&gt;&lt;SPAN class="mw-headline" id="Best_Practice:_Just_Don.27t_Do_It"&gt;Best Practice: Just Don't Do It&lt;/SPAN&gt;&lt;/H2&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;I'd bet there's a better way to do what you're doing especially if the subsets are sized at 100.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;EDIT: Here's the link &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="mw-headline"&gt;&lt;A href="http://www.sascommunity.org/wiki/Split_Data_into_Subsets" title="http://www.sascommunity.org/wiki/Split_Data_into_Subsets"&gt;Split Data into Subsets - sasCommunity&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 21:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-subsets-of-data-first-contain-the-first-100-obs-second/m-p/171303#M32892</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-12-12T21:38:15Z</dc:date>
    </item>
  </channel>
</rss>

