<?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: Selecting first 3 observations based on conditions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selecting-first-3-observations-based-on-conditions/m-p/501245#M133623</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Measure $ Date :mmddyy10. Output;
format date mmddyy10.;
datalines;
1 A 010117 1
1 A 020117 2
1 A 030117 3
1 A 060118 1
1 A 070118 2
1 A 080118 3
2 A 010116 1
2 A 020116 2
2 A 030116 3
3 A 010116 1
3 A 020116 2
3 A 030116 3
3 B 010116 1
3 B 020116 2 
3 B 030116 3
;

data want;
do _n_=1 by 1 until( last.measure);
set have;
by id measure;
if _n_&amp;lt;=3 then output;
/*else continue;*/
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 03 Oct 2018 18:49:33 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-10-03T18:49:33Z</dc:date>
    <item>
      <title>Selecting first 3 observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-first-3-observations-based-on-conditions/m-p/501243#M133621</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following data table below.&amp;nbsp; I only want to keep the first 3 observation output for each ID and Measure.&amp;nbsp; Any help would be greatly appreciated.&amp;nbsp; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
input ID Measure Date :mmddyy10. Output;
format date mmddyy10.;
datalines;&lt;BR /&gt;&lt;BR /&gt;1 A 010117 1&lt;BR /&gt;1 A 020117 2&lt;BR /&gt;1 A 030117 3&lt;BR /&gt;1 A 060118 1&lt;BR /&gt;1 A 070118 2&lt;BR /&gt;1 A 080118 3&lt;BR /&gt;2 A 010116 1&lt;BR /&gt;2 A 020116 2&lt;BR /&gt;2 A 030116 3&lt;BR /&gt;3 A 010116 1&lt;BR /&gt;3 A 020116 2&lt;BR /&gt;3 A 030116 3&lt;BR /&gt;3 B 010116 1&lt;BR /&gt;3 B 020116 2 &lt;BR /&gt;3 B 030116 3&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;data want;
input ID Measure Date :mmddyy10. Output;
format date mmddyy10.;
datalines;&lt;BR /&gt;&lt;BR /&gt;1 A 010117 1&lt;BR /&gt;1 A 020117 2&lt;BR /&gt;1 A 030117 3&lt;BR /&gt;2 A 010116 1&lt;BR /&gt;2 A 020116 2&lt;BR /&gt;2 A 030116 3&lt;BR /&gt;3 A 010116 1&lt;BR /&gt;3 A 020116 2&lt;BR /&gt;3 A 030116 3&lt;BR /&gt;3 B 010116 1&lt;BR /&gt;3 B 020116 2&lt;BR /&gt;3 B 030116 3&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 18:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-first-3-observations-based-on-conditions/m-p/501243#M133621</guid>
      <dc:creator>thb</dc:creator>
      <dc:date>2018-10-03T18:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting first 3 observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-first-3-observations-based-on-conditions/m-p/501245#M133623</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID Measure $ Date :mmddyy10. Output;
format date mmddyy10.;
datalines;
1 A 010117 1
1 A 020117 2
1 A 030117 3
1 A 060118 1
1 A 070118 2
1 A 080118 3
2 A 010116 1
2 A 020116 2
2 A 030116 3
3 A 010116 1
3 A 020116 2
3 A 030116 3
3 B 010116 1
3 B 020116 2 
3 B 030116 3
;

data want;
do _n_=1 by 1 until( last.measure);
set have;
by id measure;
if _n_&amp;lt;=3 then output;
/*else continue;*/
end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Oct 2018 18:49:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-first-3-observations-based-on-conditions/m-p/501245#M133623</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-10-03T18:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting first 3 observations based on conditions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selecting-first-3-observations-based-on-conditions/m-p/501249#M133626</link>
      <description>&lt;P&gt;THANK YOU so much! It worked perfectly.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 18:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selecting-first-3-observations-based-on-conditions/m-p/501249#M133626</guid>
      <dc:creator>thb</dc:creator>
      <dc:date>2018-10-03T18:49:46Z</dc:date>
    </item>
  </channel>
</rss>

