<?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 first and last observations  using proc sql in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34165#M8306</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
  i need first and last observations in by group using proc sql;&lt;BR /&gt;
&lt;BR /&gt;
Ex:&lt;BR /&gt;
I have three variables A,B,C. i need the out put first and last variables of B and group by A , B.&lt;BR /&gt;
101 140 220&lt;BR /&gt;
101 142 230&lt;BR /&gt;
101 148 259&lt;BR /&gt;
101 145 258&lt;BR /&gt;
102 123 339&lt;BR /&gt;
102 229 332&lt;BR /&gt;
102 227 389&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
output:&lt;BR /&gt;
101 140 220&lt;BR /&gt;
101 148 259&lt;BR /&gt;
102 123 339&lt;BR /&gt;
102 229 332&lt;BR /&gt;
&lt;BR /&gt;
 Thanks &amp;amp; Regards&lt;BR /&gt;
Slone</description>
    <pubDate>Wed, 20 May 2009 06:54:19 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-05-20T06:54:19Z</dc:date>
    <item>
      <title>first and last observations  using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34165#M8306</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
  i need first and last observations in by group using proc sql;&lt;BR /&gt;
&lt;BR /&gt;
Ex:&lt;BR /&gt;
I have three variables A,B,C. i need the out put first and last variables of B and group by A , B.&lt;BR /&gt;
101 140 220&lt;BR /&gt;
101 142 230&lt;BR /&gt;
101 148 259&lt;BR /&gt;
101 145 258&lt;BR /&gt;
102 123 339&lt;BR /&gt;
102 229 332&lt;BR /&gt;
102 227 389&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
output:&lt;BR /&gt;
101 140 220&lt;BR /&gt;
101 148 259&lt;BR /&gt;
102 123 339&lt;BR /&gt;
102 229 332&lt;BR /&gt;
&lt;BR /&gt;
 Thanks &amp;amp; Regards&lt;BR /&gt;
Slone</description>
      <pubDate>Wed, 20 May 2009 06:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34165#M8306</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-20T06:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observations  using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34166#M8307</link>
      <description>Since SQL is a column based language, doing calculations according to row numbers is not SQL's cup of tea. Maybe you can do some complicated query using the unsupported monotonic function. But, this is so much easier done with data step. Do you have reason for not using the data step?&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Wed, 20 May 2009 08:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34166#M8307</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-05-20T08:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observations  using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34167#M8308</link>
      <description>Thank u  LINUS &lt;BR /&gt;
&lt;BR /&gt;
i have a dataset  size 100GB  and 400 variables. if i run proc sort it will take 4 hours. and agian i need to run data step for first.variable and last.variable. thats why i need other than this process.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank's &amp;amp; Regards&lt;BR /&gt;
Slone</description>
      <pubDate>Wed, 20 May 2009 09:48:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34167#M8308</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-20T09:48:19Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observations  using proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34168#M8309</link>
      <description>Well, not so surprisingly, SQL needs also to do a sort before it does group by, so I don't think you are gaining so much, just because you don't explicitly code a sort.&lt;BR /&gt;
If you are concerned about I/O, maybe you could try a SQL ORDER BY view, which probably result in fewer R/W operations. Be sure to use as much memory as possible to minimize swapping.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Wed, 20 May 2009 09:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/first-and-last-observations-using-proc-sql/m-p/34168#M8309</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-05-20T09:57:39Z</dc:date>
    </item>
  </channel>
</rss>

