<?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 Programming 1 Lesson 5: IDGROUP query in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702379#M9543</link>
    <description>&lt;P&gt;The value of MONTH is not considered at all by the PROC since you never referenced it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is using the values of VISITERS and PARKNAME from the three observations with the maximum value of VISITOR within the group of observations defined by the combination of REGION and YEAR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only reason it looks to like it has anything to do with months in because in your dataset there is a MONTH variable to distinguish the multiple observations per region and year combination&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you had daily counts instead of monthly counts (so 365 observations per region per year instead of just 12) then the top 3 would be the top daily counts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to see the month that corresponds to the values of VISITORS that you are outputting add it into the list of variables to select.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;idgroup(max(Visitors) out[3] (Visitors ParkName Month)=)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Nov 2020 01:51:08 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2020-11-30T01:51:08Z</dc:date>
    <item>
      <title>SAS Programming 1 Lesson 5: IDGROUP query</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702240#M9539</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have question pertaining to the challenger question in SAS programming 1 Lesson 5 - Analyzing and Reporting on Data.&lt;/P&gt;&lt;P&gt;Image below shows the solution to the "Challenger" practice of Topic "Creating Summary Reports and Data".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-11-29 131656.png" style="width: 782px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52078iF46DD9B7CF79E1F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-11-29 131656.png" alt="Screenshot 2020-11-29 131656.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;My question:&lt;/P&gt;&lt;P&gt;Why didn't the proc means step creating the output of top 3 parks grouped by REGION and YEARS?&lt;/P&gt;&lt;P&gt;The answer for 188594 is the third highest number of park visitors in Alaska region in the month of &lt;U&gt;&lt;STRONG&gt;JUNE&lt;/STRONG&gt;&lt;/U&gt; of year 2010.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I were to sum the total of visitors by YEARS and REGION, what would the code look like?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Siroo&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 05:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702240#M9539</guid>
      <dc:creator>Siroo</dc:creator>
      <dc:date>2020-11-29T05:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programming 1 Lesson 5: IDGROUP query</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702323#M9541</link>
      <description>&lt;P&gt;The whole point of the IDGROUP is to let you output some of the individual values that are used to create the aggregate values that the normal options on the OUTPUT statement let you create.&amp;nbsp; Sounds like from your description the third largest number of visitors to the Alaska region during the year 2010 occurred in the month of June.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example you can run that does not require the datasets from that course.&lt;/P&gt;
&lt;P&gt;The CLASS statement will group the data by CLASS and the two IDGROUP will get some of the detail information for the two tallest and two shortest in the group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=sashelp.class nway ;
  class sex;
  var height ;
  output out=summary max=max min=min
    idgroup (max(height) out[2] (name height)=tall_name tall_height )
    idgroup (min(height) out[2] (name height)=short_name short_height ) 
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;                                tall_   tall_    tall_    tall_  short_ short_  short_   short_
Obs Sex _TYPE_ _FREQ_  max  min name_1 name_2  height_1 height_2 name_1 name_2 height_1 height_2

 1   F     1      9   66.5 51.3 Mary   Barbara   66.5     65.3   Joyce  Louise   51.3     56.3
 2   M     1     10   72.0 57.3 Philip Alfred    72.0     69.0   James  Thomas   57.3     57.5
&lt;/PRE&gt;
&lt;P&gt;So you can see that the tallest boy is Philip and the shortest girl Joyce.&amp;nbsp; But you can also see that the second shortest boy is Thomas and the second tallest girl is Barbara.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 18:24:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702323#M9541</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-29T18:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programming 1 Lesson 5: IDGROUP query</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702373#M9542</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;Let's assume the dataset comes with the variable REGION, MONTH, YEAR, PARKNAME and VISITORS.&lt;/P&gt;&lt;P&gt;The result of code below would return the top 3 number visitors by REGION, YEAR and&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;MONTH&lt;/STRONG&gt;&lt;/U&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc means data=pg1.np_multiyr noprint;
    var Visitors;
    class Region Year;
    ways 2;
    output out=top3parks(drop=_freq_ _type_)
           sum=TotalVisitors
    	   idgroup(max(Visitors) out[3] (Visitors ParkName)=);
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS output running the above code:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-11-30 081033.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52130i10323F6F9EF8771C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-11-30 081033.png" alt="Screenshot 2020-11-30 081033.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By referring to the raw data below, 193,116 visitors is the data for Alaska in the 8th month of 2010.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-11-30 081411.png" style="width: 593px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/52131i13708614FAA7D6A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-11-30 081411.png" alt="Screenshot 2020-11-30 081411.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am just wondering since the code only classify the VISITORS by REGION and YEAR, why would "MONTH" be considered when there is no MONTH variable in the code?&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 00:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702373#M9542</guid>
      <dc:creator>Siroo</dc:creator>
      <dc:date>2020-11-30T00:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Programming 1 Lesson 5: IDGROUP query</title>
      <link>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702379#M9543</link>
      <description>&lt;P&gt;The value of MONTH is not considered at all by the PROC since you never referenced it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is using the values of VISITERS and PARKNAME from the three observations with the maximum value of VISITOR within the group of observations defined by the combination of REGION and YEAR.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The only reason it looks to like it has anything to do with months in because in your dataset there is a MONTH variable to distinguish the multiple observations per region and year combination&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you had daily counts instead of monthly counts (so 365 observations per region per year instead of just 12) then the top 3 would be the top daily counts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to see the month that corresponds to the values of VISITORS that you are outputting add it into the list of variables to select.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;idgroup(max(Visitors) out[3] (Visitors ParkName Month)=)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Nov 2020 01:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/SAS-Programming-1-Lesson-5-IDGROUP-query/m-p/702379#M9543</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-30T01:51:08Z</dc:date>
    </item>
  </channel>
</rss>

