<?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: Outputting the first observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534353#M146622</link>
    <description>What result would you want if the order of p over time is&lt;BR /&gt;&lt;BR /&gt;68&lt;BR /&gt;70&lt;BR /&gt;68&lt;BR /&gt;&lt;BR /&gt;Should 68 appear twice?&lt;BR /&gt;&lt;BR /&gt;It is possible that this program provides the proper result without sorting &lt;BR /&gt;&lt;BR /&gt;Data want;&lt;BR /&gt;Set have;&lt;BR /&gt;By p notsorted;&lt;BR /&gt;If first.p;&lt;BR /&gt;Run;</description>
    <pubDate>Mon, 11 Feb 2019 00:49:53 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-02-11T00:49:53Z</dc:date>
    <item>
      <title>Outputting the first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534349#M146619</link>
      <description>&lt;P&gt;Dear All:&lt;/P&gt;&lt;P&gt;My data set is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ID&lt;/P&gt;&lt;P&gt;9:00:01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 56.57&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;45&lt;/P&gt;&lt;P&gt;9:00:01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 67.97&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;46&lt;/P&gt;&lt;P&gt;9:00:01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 67.97&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;46&lt;/P&gt;&lt;P&gt;9:00:01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;68.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&lt;/P&gt;&lt;P&gt;9:00:02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 69.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 76&lt;/P&gt;&lt;P&gt;9:00:02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 69.10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 79&lt;/P&gt;&lt;P&gt;9:00:02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 70.01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&lt;/P&gt;&lt;P&gt;9:00:03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 69.04&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 78&lt;/P&gt;&lt;P&gt;9:00:03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 68.10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and so on&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output I want is the p observation.&amp;nbsp; So in this example I need:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Time&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ID&lt;/P&gt;&lt;P&gt;9:00:01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 56.57&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;45&lt;/P&gt;&lt;P&gt;9:00:01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 67.97&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;46&lt;/P&gt;&lt;P&gt;9:00:01&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;68.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&lt;/P&gt;&lt;P&gt;9:00:02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 69.00&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 76&lt;/P&gt;&lt;P&gt;9:00:02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 69.10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 79&lt;/P&gt;&lt;P&gt;9:00:02&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 56.57&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 45&lt;/P&gt;&lt;P&gt;9:00:03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 69.04&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 78&lt;/P&gt;&lt;P&gt;9:00:03&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 68.10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code I wrote was&lt;/P&gt;&lt;P&gt;data want; set have;&lt;/P&gt;&lt;P&gt;by ID p time:&lt;/P&gt;&lt;P&gt;If first.p then output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some thing does not seem to work with the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;R&lt;/P&gt;</description>
      <pubDate>Sun, 10 Feb 2019 23:53:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534349#M146619</guid>
      <dc:creator>RandyStan</dc:creator>
      <dc:date>2019-02-10T23:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Outputting the first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534351#M146620</link>
      <description>&lt;P&gt;Perhaps your values are not actually exactly the same?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 00:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534351#M146620</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-02-11T00:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Outputting the first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534352#M146621</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Time  :time8.                p                  ID;
format time time8.;
cards;
9:00:01              56.57           45
9:00:01              67.97           46
9:00:01              67.97           46
9:00:01               68.00          46
9:00:02              69.00            76
9:00:02              69.10            79
9:00:02              70.01            45
9:00:03              69.04            78
9:00:03              68.10            4
;
proc sort data=have out=_have;
by id p time;
run;
data want; set _have;

by ID p time;

If first.p then output;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Feb 2019 00:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534352#M146621</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-11T00:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Outputting the first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534353#M146622</link>
      <description>What result would you want if the order of p over time is&lt;BR /&gt;&lt;BR /&gt;68&lt;BR /&gt;70&lt;BR /&gt;68&lt;BR /&gt;&lt;BR /&gt;Should 68 appear twice?&lt;BR /&gt;&lt;BR /&gt;It is possible that this program provides the proper result without sorting &lt;BR /&gt;&lt;BR /&gt;Data want;&lt;BR /&gt;Set have;&lt;BR /&gt;By p notsorted;&lt;BR /&gt;If first.p;&lt;BR /&gt;Run;</description>
      <pubDate>Mon, 11 Feb 2019 00:49:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534353#M146622</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-02-11T00:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Outputting the first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534355#M146623</link>
      <description>&lt;P&gt;Your sample data appears to be sorted by TIME/P/ID.&amp;nbsp; if that's true, then your idea of a data step with a BY statement and a"first." condition is&amp;nbsp;correct, but needs tweaking, assuming what you want is to eliminate duplicate&amp;nbsp;time/p/id combinations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by time p id;
  if first.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course this means a given id&amp;nbsp; or a given P can appears more than once for a given TIME.&amp;nbsp; I presume that's ok.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 01:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534355#M146623</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-02-11T01:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Outputting the first observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534360#M146626</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you trying to remove duplicate records, try the nodupkey option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=want nodupkey;
by id p time;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Feb 2019 02:46:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Outputting-the-first-observation/m-p/534360#M146626</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2019-02-11T02:46:41Z</dc:date>
    </item>
  </channel>
</rss>

