<?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: First. In proc sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248978#M46791</link>
    <description>&lt;P&gt;Yes, i am heavily depend on the&amp;nbsp;&lt;SPAN&gt;assumptions of marks ordered.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Anyway,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71683"&gt;@Ps8813﻿&lt;/a&gt;&amp;nbsp;too much sweet is harmful!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Feb 2016 17:35:12 GMT</pubDate>
    <dc:creator>mohamed_zaki</dc:creator>
    <dc:date>2016-02-09T17:35:12Z</dc:date>
    <item>
      <title>First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248931#M46774</link>
      <description>Hi , i have a small and sweet question.&lt;BR /&gt;I want to change below code in proc sql.&lt;BR /&gt;&lt;BR /&gt;Data test;&lt;BR /&gt;Set marks;&lt;BR /&gt;By stdid;&lt;BR /&gt;If first.stdid;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;Marks&lt;BR /&gt;____________&lt;BR /&gt;Stdid. Marks&lt;BR /&gt;1. 34&lt;BR /&gt;1. 43&lt;BR /&gt;2. 54&lt;BR /&gt;2. 60&lt;BR /&gt;2. 65&lt;BR /&gt;&lt;BR /&gt;Test&lt;BR /&gt;________________&lt;BR /&gt;Stdid. Marks&lt;BR /&gt;1. 34&lt;BR /&gt;2. 54&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 09 Feb 2016 16:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248931#M46774</guid>
      <dc:creator>Ps8813</dc:creator>
      <dc:date>2016-02-09T16:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248943#M46776</link>
      <description>&lt;P&gt;Nope, doesn't exist. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to find some other logic, how is your first record identified?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 16:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248943#M46776</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-09T16:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248952#M46780</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input stdid Marks;
cards;
1 34
1 43
2 54
2 60
2 65
;
run;

proc sql ;
select *
FROM  have h1
where marks=(select MIN(Marks) from have h2 where h1.stdid=h2.stdid)
order BY stdid;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Feb 2016 16:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248952#M46780</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-09T16:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248954#M46781</link>
      <description>&lt;P&gt;I am second to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza﻿&lt;/a&gt;'s comments, you can't get it done using Proc SQL without involving some 'extraordinary measures', I mean 'undocumented/unsupported feature', such as the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table test as
select * from have
group by stdid
having monotonic()=min(monotonic())
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;monotonic() is not officially supported by SAS, use it at your own risk. However,&amp;nbsp;this implementation&amp;nbsp;is the closest&amp;nbsp;I can think of to your data step counterpart 'first.'.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 16:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248954#M46781</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-02-09T16:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248955#M46782</link>
      <description>&lt;P&gt;Read more here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/publishing/2015/01/08/sas-authors-tip-identifying-first-row-and-last-row-in-by-groups/" target="_self"&gt;SAS author's tip: Identifying FIRST.row and LAST.row in by-groups&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 16:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248955#M46782</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-09T16:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248958#M46784</link>
      <description>&lt;P&gt;Won't be the same if there is dups&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Stdid Marks;
cards;
1 34
1 34
1 43
2 54
2 60
2 65
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Feb 2016 17:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248958#M46784</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-02-09T17:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248969#M46788</link>
      <description>&lt;P&gt;If no more columns&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
select distinct *
FROM  have h1
where marks=(select MIN(Marks) from have h2 where h1.stdid=h2.stdid)
order BY stdid
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Feb 2016 17:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248969#M46788</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-09T17:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248970#M46789</link>
      <description>&lt;P&gt;At the risk of being obnoxious, what I was trying to say is not you can generate the same results, rather, is&amp;nbsp;that your SQL logic is not to mirror 'first.', as you have heavily depended on some other assumptions. What if this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Stdid Marks;
cards;
1 36
1 34
1 43
2 54
2 60
2 65
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Feb 2016 17:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248970#M46789</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-02-09T17:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248975#M46790</link>
      <description>&lt;P&gt;Thank u all for quick replying. Both below codes are working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1:-&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select * from test group by stdid having monotonic()=min(monotonic());&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;2:-&lt;/P&gt;&lt;P&gt;proc sql ;&lt;BR /&gt;select *&lt;BR /&gt;FROM test h1&lt;BR /&gt;where marks=(select MIN(Marks) from test h2 where h1.stdid=h2.stdid)&lt;BR /&gt;order BY stdid;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Though second solution wont give correct result when we have duplicate marks for same stdid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 17:32:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248975#M46790</guid>
      <dc:creator>Ps8813</dc:creator>
      <dc:date>2016-02-09T17:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: First. In proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248978#M46791</link>
      <description>&lt;P&gt;Yes, i am heavily depend on the&amp;nbsp;&lt;SPAN&gt;assumptions of marks ordered.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Anyway,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71683"&gt;@Ps8813﻿&lt;/a&gt;&amp;nbsp;too much sweet is harmful!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 17:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/First-In-proc-sql/m-p/248978#M46791</guid>
      <dc:creator>mohamed_zaki</dc:creator>
      <dc:date>2016-02-09T17:35:12Z</dc:date>
    </item>
  </channel>
</rss>

