<?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: Why does this GROUP BY statement fail? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545777#M8091</link>
    <description>&lt;P&gt;I am afraid all I can see here is "This works" "this does not", no examples or anything.&amp;nbsp; Let me put it this way, in a SAS session I just put the code:&lt;/P&gt;
&lt;PRE&gt;Data rawdata;
input v1 v2;
datalines;
2 3
2 4
6 4 
8 9
2 4
;
run;
PROC SQL;
SELECT mean(v2) as v3
FROM rawdata
GROUP BY v1;
quit;&lt;/PRE&gt;
&lt;P&gt;Which gives the log:&lt;/P&gt;
&lt;PRE&gt;289        Data rawdata;
290        input v1 v2;
291        datalines;

NOTE: The data set WORK.RAWDATA has 5 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

297        ;
298        run;
299        PROC SQL;
300        SELECT mean(v2) as v3
301        FROM rawdata
302        GROUP BY v1;
303        quit;
NOTE: The PROCEDURE SQL printed page 2.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;And produces in the listing file the output;&lt;/P&gt;
&lt;PRE&gt;/**********************************************************************************************************************
 * Submission Start: Untitled.sas*
 * Mar 25, 2019 12:29:01 GMT by ***
 *********************************************************************************************************************/
                                          The SAS System          12:29 Monday, March 25, 2019   2

                                                   v3
                                             --------
                                             3.666667
                                                    4
                                                    9

/**********************************************************************************************************************
 * Submission End: Untitled.sas*
 * Mar 25, 2019 12:29:01 GMT
 *********************************************************************************************************************/&lt;/PRE&gt;
&lt;P&gt;So the code does "work" and produces the correct output, so what is it different about your output, what is "not working", where is it "not working", what is "supposed to happen" which is not?&amp;nbsp; If your not getting listing output then that destination has been turned off.&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2019 12:30:54 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2019-03-25T12:30:54Z</dc:date>
    <item>
      <title>Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545719#M8064</link>
      <description>&lt;P&gt;I'm working through the advanced programmer prep guide, double checking the examples on the way to make sure I undestand.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The book (i think) states that if we type AVG(variable1) and then GROUP BY(variable2) we will get one average of Variable1 for each value of Variable2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I submit the folloinw code, (createing the raw data)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Data rawdata;
input v1 v2;
datalines;
2 3
2 4
6 4 
8 9
2 4
;
run;&lt;/PRE&gt;&lt;P&gt;I then perform the operations in PROC SQL, substituting AVG() for MEAN() since AVG(( isn't part of base SAS and thus can't be used in PROC SQL:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC SQL;
SELECT mean(v2) as v3
FROM rawdata
GROUP BY v1;
quit;&lt;/PRE&gt;&lt;P&gt;Why does this fail to execute?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As fas as I can see, four values should be generated. One for each distinct value of v1 and an average ((3+4/)2)when v1=2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 09:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545719#M8064</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-03-25T09:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545722#M8065</link>
      <description>&lt;P&gt;Please share the full log with any messages, e.g.:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;13         Data rawdata;
14         input v1 v2;
15         datalines;

NOTE: Compression was disabled for data set WORK.RAWDATA because compression overhead would increase the size of the data set.
NOTE: The data set WORK.RAWDATA has 5 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

21         ;
22         run;
23         
24         PROC SQL;
25         SELECT mean(v2) as v3
26         FROM rawdata
27         GROUP BY v1;
28         quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.01 seconds
      cpu time            0.02 seconds&lt;/PRE&gt;&lt;P&gt;Please clarify what you mean by "fails to execute".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try selecting v1 in your &lt;FONT face="courier new,courier"&gt;select&lt;/FONT&gt; statement to see if that makes a difference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 10:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545722#M8065</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2019-03-25T10:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545726#M8068</link>
      <description>&lt;P&gt;There's really nothing in th log to write home about, I tried including var1 in the SELECT statement, yielding exactly the same result:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;297 Data rawdata;&lt;BR /&gt;298 input v1 v2;&lt;BR /&gt;299 datalines;&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.RAWDATA has 5 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;305 ;&lt;BR /&gt;306 run;&lt;BR /&gt;307&lt;BR /&gt;308 PROC SQL FEEDBACK;&lt;BR /&gt;309 SELECT mean(v2) as v3&lt;BR /&gt;310 FROM rawdata&lt;BR /&gt;311 GROUP BY v1;&lt;BR /&gt;NOTE: Statement transforms to:&lt;/P&gt;&lt;P&gt;select MEAN(RAWDATA.v2) as v3&lt;BR /&gt;from WORK.RAWDATA&lt;BR /&gt;group by RAWDATA.v1;&lt;/P&gt;&lt;P&gt;312 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.05 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 25 Mar 2019 10:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545726#M8068</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-03-25T10:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545728#M8070</link>
      <description>&lt;P&gt;Here's the log with v1 included:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;313 PROC SQL FEEDBACK;&lt;BR /&gt;314 SELECT v1, mean(v2) as v3&lt;BR /&gt;315 FROM rawdata&lt;BR /&gt;316 GROUP BY v1;&lt;BR /&gt;NOTE: Statement transforms to:&lt;/P&gt;&lt;P&gt;select RAWDATA.v1, MEAN(RAWDATA.v2) as v3&lt;BR /&gt;from WORK.RAWDATA&lt;BR /&gt;group by RAWDATA.v1;&lt;/P&gt;&lt;P&gt;317 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.06 seconds&lt;BR /&gt;cpu time 0.03 seconds&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 25 Mar 2019 10:50:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545728#M8070</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-03-25T10:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545729#M8071</link>
      <description>&lt;P&gt;When I say fails to execute I say that in a figurative sense, e.g "nothing happens", "no output is produced".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 10:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545729#M8071</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-03-25T10:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545763#M8083</link>
      <description>&lt;P&gt;What output do you want?&amp;nbsp; The default - so long as you haven't turned the destination off - for SQL output is the list file (could be called listing).&amp;nbsp; You should be able to see it in there.&amp;nbsp; If you want a dataset, then you need the create table statement:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table want as 
  select ...
quit;&lt;/PRE&gt;
&lt;P&gt;So a dataset called want (in this case) will be created with the results of the query.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545763#M8083</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-25T12:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545767#M8087</link>
      <description>&lt;P&gt;I would settle for standard output or any output at all really, but none is produced?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:05:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545767#M8087</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-03-25T12:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545770#M8089</link>
      <description>&lt;P&gt;Then you must have turned off the listing destination with something like:&lt;/P&gt;
&lt;PRE&gt;ods listing close;

or 

ods _all_ close;&lt;/PRE&gt;
&lt;P&gt;Print output from procedures default to listing destination, if thats closed you wouldn't get anything.&amp;nbsp; You can do:&lt;/P&gt;
&lt;PRE&gt;ods listing;&lt;/PRE&gt;
&lt;P&gt;Before your code to ensure it is on.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545770#M8089</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-25T12:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545772#M8090</link>
      <description>No. I haven't worked with the ods system today. Also, this statement works&lt;BR /&gt;flawlessly ("and" produces output) as soon as the GROUP BY statement is&lt;BR /&gt;removed.&lt;BR /&gt;&lt;BR /&gt;This has nothing to do with ODS.&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545772#M8090</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-03-25T12:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545777#M8091</link>
      <description>&lt;P&gt;I am afraid all I can see here is "This works" "this does not", no examples or anything.&amp;nbsp; Let me put it this way, in a SAS session I just put the code:&lt;/P&gt;
&lt;PRE&gt;Data rawdata;
input v1 v2;
datalines;
2 3
2 4
6 4 
8 9
2 4
;
run;
PROC SQL;
SELECT mean(v2) as v3
FROM rawdata
GROUP BY v1;
quit;&lt;/PRE&gt;
&lt;P&gt;Which gives the log:&lt;/P&gt;
&lt;PRE&gt;289        Data rawdata;
290        input v1 v2;
291        datalines;

NOTE: The data set WORK.RAWDATA has 5 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

297        ;
298        run;
299        PROC SQL;
300        SELECT mean(v2) as v3
301        FROM rawdata
302        GROUP BY v1;
303        quit;
NOTE: The PROCEDURE SQL printed page 2.
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;And produces in the listing file the output;&lt;/P&gt;
&lt;PRE&gt;/**********************************************************************************************************************
 * Submission Start: Untitled.sas*
 * Mar 25, 2019 12:29:01 GMT by ***
 *********************************************************************************************************************/
                                          The SAS System          12:29 Monday, March 25, 2019   2

                                                   v3
                                             --------
                                             3.666667
                                                    4
                                                    9

/**********************************************************************************************************************
 * Submission End: Untitled.sas*
 * Mar 25, 2019 12:29:01 GMT
 *********************************************************************************************************************/&lt;/PRE&gt;
&lt;P&gt;So the code does "work" and produces the correct output, so what is it different about your output, what is "not working", where is it "not working", what is "supposed to happen" which is not?&amp;nbsp; If your not getting listing output then that destination has been turned off.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 12:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545777#M8091</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-25T12:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545810#M8096</link>
      <description>&lt;P&gt;I see now there was an issue with my "Result viewer" window, which resolved itself when I restarted SAS. I will mark this as the answer since it indicated the problem wasn't with my code byt with my current SAS session.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 13:46:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545810#M8096</guid>
      <dc:creator>Syntas_error</dc:creator>
      <dc:date>2019-03-25T13:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545829#M8099</link>
      <description>&lt;P&gt;Not too sound too much like IT, "Have you turned it off and on again".&amp;nbsp; I would assume ods destinations had been closed, hence no output.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 14:05:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545829#M8099</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-25T14:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why does this GROUP BY statement fail?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545843#M8102</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/254512"&gt;@Syntas_error&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I see now there was an issue with my "Result viewer" window, which resolved itself when I restarted SAS. I will mark this as the answer since it indicated the problem wasn't with my code byt with my current SAS session.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your example log did not show a No output destinations active message I would be interested to see if you ever checked the OUTPUT window, not just the Results.&lt;/P&gt;
&lt;P&gt;If something has turned off ODS HTML but ODS LIsting is active there is no message in the log but the results of your SQL (or any other procedure) would go to the LISTING destination, i.e. the OUTPUT window.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2019 14:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Why-does-this-GROUP-BY-statement-fail/m-p/545843#M8102</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-25T14:32:14Z</dc:date>
    </item>
  </channel>
</rss>

