<?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: If first statements in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119692#M32993</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are trying to select the first records for each school under each stukey, then try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Data Enr2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Enr;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY STUKEY SCHOOL;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF FIRST.SCHOOL;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Nov 2012 16:46:37 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2012-11-07T16:46:37Z</dc:date>
    <item>
      <title>If first statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119691#M32992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I am trying to select the first observation from two different variables and my code does not seem to be working.&amp;nbsp; Can anyone help me.&amp;nbsp; The code does not return the correct records.&amp;nbsp; There could be the same stukey in different schools and I am trying to capture the stukey in every school.&amp;nbsp; Code is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data Enr2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Enr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY STUKEY SCHOOL;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF FIRST.STUKEY AND FIRST.SCHOOL; RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 16:42:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119691#M32992</guid>
      <dc:creator>SannaSanna</dc:creator>
      <dc:date>2012-11-07T16:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: If first statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119692#M32993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are trying to select the first records for each school under each stukey, then try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Data Enr2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Enr;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY STUKEY SCHOOL;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF FIRST.SCHOOL;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 16:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119692#M32993</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-11-07T16:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: If first statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119693#M32994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you do a BY statement you have an indicator variable for each by variable that says first and last.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So by selecting first.stukeyand first.school your saying give me the records where its is the first stukey AND the first school, which is the same as saying first.stukey essentially.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you say first.school, everytime school changes (and by default the stukey) that record will be output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 17:18:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119693#M32994</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-11-07T17:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: If first statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119694#M32995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am not sure what you are try to find.&amp;nbsp; The following will determine students that attend more than one school and also students in each school.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data enr;&lt;BR /&gt;input stukey $ school $;&lt;BR /&gt;datalines;&lt;BR /&gt;1 a&lt;BR /&gt;1 a&lt;BR /&gt;1 b&lt;BR /&gt;1 b&lt;BR /&gt;1 b&lt;BR /&gt;2 a&lt;BR /&gt;2 b&lt;BR /&gt;2 c&lt;BR /&gt;3 b&lt;BR /&gt;4 d&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=enr nodupkey;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; by stukey school ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;Data dups each;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set Enr;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BY stukey school ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF not(FIRST.STUKEY and last.stukey) then output dups; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.school then output each;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; RUN;&lt;BR /&gt;title1 students in more than one school;&lt;BR /&gt;proc print data=dups;&lt;BR /&gt;run;&lt;BR /&gt;title1 Student school combinations;&lt;BR /&gt;proc print data=each;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Nov 2012 18:58:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/If-first-statements/m-p/119694#M32995</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-11-07T18:58:56Z</dc:date>
    </item>
  </channel>
</rss>

