<?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: SAS course no. 2, p202a04.sas, official solution does not do what it's supposed to do? in Programming 1 and 2</title>
    <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-course-no-2-p202a04-sas-official-solution-does-not-do-what/m-p/647503#M510</link>
    <description>&lt;P&gt;Hello &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Oh yes yes of course, that makes sense!&lt;BR /&gt;It now worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Miriam&lt;/P&gt;</description>
    <pubDate>Wed, 13 May 2020 15:30:50 GMT</pubDate>
    <dc:creator>miriam93</dc:creator>
    <dc:date>2020-05-13T15:30:50Z</dc:date>
    <item>
      <title>SAS course no. 2, p202a04.sas, official solution does not do what it's supposed to do?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-course-no-2-p202a04-sas-official-solution-does-not-do-what/m-p/647478#M508</link>
      <description>&lt;P&gt;Dear SAS community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I installed the University edition of SAS last week and am now working through the SAS online course no. 2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code (activity 2.04), which is my solution and also the official solution, is supposed to produce a table with 5 rows, one for each value of basin (the one with the highest MaxWindMPH).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, if I run this, I get a table with 54 rows and multiple entries for identical values of 'Basin'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;***********************************************************;
*  Activity 2.04                                          *;
*  1) Change the WHERE statement to a subsetting IF       *;
*     statement and submit the program. How many rows are *;
*     included in the output table?                       *;
*  2) Move the subsetting IF statement just before the    *;
*     RUN statement and submit the program. How many rows *;
*     are included in the output table?                   *;
*  3) Consider the sequence of the statements in the      *;
*     execution phase. Where is the optimal placement of  *;
*     the subsetting IF statement?                        *;
***********************************************************;
proc sort data=pg2.storm_2017 out=storm2017_sort;
	by Basin MaxWindMPH;
run;

data storm2017_max;
    set storm2017_sort;
    by Basin;&lt;BR /&gt;&lt;FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.Basin=1;&lt;/FONT&gt;
    StormLength=EndDate-StartDate;
    MaxWindKM=MaxWindMPH*1.60934;
run;  &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, my question: &lt;STRONG&gt;Is there simply a mistake in this solution (which, just by chance, I also made in my solution) or has there been an update in SAS which changed the behaviour/usage of last.myvariable/first.myvariable?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I naively expected that this code sorts the input data according to Basin and then decsending wind speed, and by last.Basin=1 only keeps the last entry for each basin, the one with the highest wind speed.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS Studio for my studies.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Miriam&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-course-no-2-p202a04-sas-official-solution-does-not-do-what/m-p/647478#M508</guid>
      <dc:creator>miriam93</dc:creator>
      <dc:date>2020-05-13T14:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS course no. 2, p202a04.sas, official solution does not do what it's supposed to do?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-course-no-2-p202a04-sas-official-solution-does-not-do-what/m-p/647499#M509</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327241"&gt;@miriam93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear SAS community,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I installed the University edition of SAS last week and am now working through the SAS online course no. 2.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following code (activity 2.04), which is my solution and also the official solution, is supposed to produce a table with 5 rows, one for each value of basin (the one with the highest MaxWindMPH).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if I run this, I get a table with 54 rows and multiple entries for identical values of 'Basin'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;***********************************************************;
*  Activity 2.04                                          *;
*  1) Change the WHERE statement to a subsetting IF       *;
*     statement and submit the program. How many rows are *;
*     included in the output table?                       *;
*  2) Move the subsetting IF statement just before the    *;
*     RUN statement and submit the program. How many rows *;
*     are included in the output table?                   *;
*  3) Consider the sequence of the statements in the      *;
*     execution phase. Where is the optimal placement of  *;
*     the subsetting IF statement?                        *;
***********************************************************;
proc sort data=pg2.storm_2017 out=storm2017_sort;
	by Basin MaxWindMPH;
run;

data storm2017_max;
    set storm2017_sort;
    by Basin;&lt;BR /&gt;&lt;FONT&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last.Basin=1;&lt;/FONT&gt;
    StormLength=EndDate-StartDate;
    MaxWindKM=MaxWindMPH*1.60934;
run;  &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, my question: &lt;STRONG&gt;Is there simply a mistake in this solution (which, just by chance, I also made in my solution) or has there been an update in SAS which changed the behaviour/usage of last.myvariable/first.myvariable?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I naively expected that this code sorts the input data according to Basin and then &lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;decsending&lt;/FONT&gt;&lt;/STRONG&gt; wind speed, and by last.Basin=1 only keeps the last entry for each basin, the one with the highest wind speed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS Studio for my studies.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your help,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Miriam&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you want data sorted by descending values then you need to add the Descending in the BY statement of the sort. Otherwise your data sorts by default smallest to largest and the Last basin value has the greatest MaxWindMPH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sort data=pg2.storm_2017 out=storm2017_sort;
	by Basin descending MaxWindMPH;
run;&lt;/PRE&gt;
&lt;P&gt;But that does not match the apparent requirement if you use LAST.basin. Descending MaxWindMPH would imply that you want FIRST.Basin for the greatest MaxWindMPH value.&lt;/P&gt;
&lt;P&gt;Show the LOG of the code you actually ran. One would suspect that if the source set and your output both have 54 records that you did not use a subsetting if statement correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 15:26:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-course-no-2-p202a04-sas-official-solution-does-not-do-what/m-p/647499#M509</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-13T15:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS course no. 2, p202a04.sas, official solution does not do what it's supposed to do?</title>
      <link>https://communities.sas.com/t5/Programming-1-and-2/SAS-course-no-2-p202a04-sas-official-solution-does-not-do-what/m-p/647503#M510</link>
      <description>&lt;P&gt;Hello &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Oh yes yes of course, that makes sense!&lt;BR /&gt;It now worked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;Miriam&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 15:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Programming-1-and-2/SAS-course-no-2-p202a04-sas-official-solution-does-not-do-what/m-p/647503#M510</guid>
      <dc:creator>miriam93</dc:creator>
      <dc:date>2020-05-13T15:30:50Z</dc:date>
    </item>
  </channel>
</rss>

