<?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 Selecting specific number of entry for each ID in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-specific-number-of-entry-for-each-ID/m-p/636767#M189222</link>
    <description>&lt;P&gt;I have a large data that includes multiple observations for each ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I only wanted to select the first entry of each ID, then the below code works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I wanted to select the first 5 entries of each ID, then what coding could I use?&lt;/P&gt;&lt;P&gt;Thanks for your help in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;if first.id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Apr 2020 05:49:25 GMT</pubDate>
    <dc:creator>SAS_AMUH</dc:creator>
    <dc:date>2020-04-02T05:49:25Z</dc:date>
    <item>
      <title>Selecting specific number of entry for each ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-specific-number-of-entry-for-each-ID/m-p/636767#M189222</link>
      <description>&lt;P&gt;I have a large data that includes multiple observations for each ID.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I only wanted to select the first entry of each ID, then the below code works.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I wanted to select the first 5 entries of each ID, then what coding could I use?&lt;/P&gt;&lt;P&gt;Thanks for your help in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set have;&lt;/P&gt;&lt;P&gt;by id;&lt;/P&gt;&lt;P&gt;if first.id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 05:49:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-specific-number-of-entry-for-each-ID/m-p/636767#M189222</guid>
      <dc:creator>SAS_AMUH</dc:creator>
      <dc:date>2020-04-02T05:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting specific number of entry for each ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-specific-number-of-entry-for-each-ID/m-p/636769#M189223</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212934"&gt;@SAS_AMUH&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a large data that includes multiple observations for each ID.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I only wanted to select the first entry of each ID, then the below code works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I wanted to select the first 5 entries of each ID, then what coding could I use?&lt;/P&gt;
&lt;P&gt;Thanks for your help in advance.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;by id;&lt;/P&gt;
&lt;P&gt;if first.id;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have to count the obs per ID, code is untestet:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id;
  length counter 8;
  retain counter;
  if first.id then counter = 0;
  counter = counter + 1;
  if counter &amp;lt;= 5;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 05:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-specific-number-of-entry-for-each-ID/m-p/636769#M189223</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-04-02T05:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting specific number of entry for each ID</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-specific-number-of-entry-for-each-ID/m-p/636774#M189225</link>
      <description>Thank you!</description>
      <pubDate>Thu, 02 Apr 2020 06:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-specific-number-of-entry-for-each-ID/m-p/636774#M189225</guid>
      <dc:creator>SAS_AMUH</dc:creator>
      <dc:date>2020-04-02T06:08:33Z</dc:date>
    </item>
  </channel>
</rss>

