<?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: PROC SQL error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518294#M140262</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	CREATE TABLE work.counts AS
		SELECT
			Report_Month,
			CASE 
				WHEN P = 'ACC' THEN 'A'
				WHEN P = 'DCL' AND S = 'ACC' THEN 'B'
				WHEN P = 'DLC' AND S = 'DLC' AND SS = 'ACC' THEN 'C'
				WHEN SS = 'DLC' THEN 'E'
			END AS Risk,
			COUNT(DISTINCT SSN) AS COUNT
		FROM work.Master
		GROUP BY 
			Report_Month,
			calculated Risk;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I removed COUNT from the group by.&amp;nbsp; I added the keyword calculated before the variable RISK.&amp;nbsp; SAS needs an identifying keyword when you use a derived column/field/variable when it is built and used&amp;nbsp;within the same query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Dec 2018 02:53:46 GMT</pubDate>
    <dc:creator>ShiroAmada</dc:creator>
    <dc:date>2018-12-04T02:53:46Z</dc:date>
    <item>
      <title>PROC SQL error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518228#M140226</link>
      <description>&lt;P&gt;I'm getting an error of Summary functions are restricted to the SELECT and HAVING ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this because I can't group by a variable in the same statement that I create it in?&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;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	CREATE TABLE work.counts AS
		SELECT
			Report_Month,
			CASE 
				WHEN P = 'ACC' THEN 'A'
				WHEN P = 'DCL' AND S = 'ACC' THEN 'B'
				WHEN P = 'DLC' AND S = 'DLC' AND SS = 'ACC' THEN 'C'
				WHEN SS = 'DLC' THEN 'E'
			END AS Risk,
			COUNT(DISTINCT SSN) AS COUNT
		FROM work.Master
		GROUP BY 
			Report_Month,
			Risk,
			Count;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Dec 2018 21:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518228#M140226</guid>
      <dc:creator>pchappus</dc:creator>
      <dc:date>2018-12-03T21:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518232#M140228</link>
      <description>&lt;P&gt;Why not just remove COUNT from the GROUP BY clause?&amp;nbsp; You're already getting one observation per REPORT_MONTH / RISK group ... COUNT doesn't need to be a grouping variable.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 21:13:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518232#M140228</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-03T21:13:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518241#M140234</link>
      <description>Put the word 'calculated' in front of any calculated variables when using it later.</description>
      <pubDate>Mon, 03 Dec 2018 21:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518241#M140234</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-12-03T21:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518245#M140236</link>
      <description>&lt;P&gt;You have a logical error. My i request sample data of what you have and want plz&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 21:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518245#M140236</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-12-03T21:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518294#M140262</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	CREATE TABLE work.counts AS
		SELECT
			Report_Month,
			CASE 
				WHEN P = 'ACC' THEN 'A'
				WHEN P = 'DCL' AND S = 'ACC' THEN 'B'
				WHEN P = 'DLC' AND S = 'DLC' AND SS = 'ACC' THEN 'C'
				WHEN SS = 'DLC' THEN 'E'
			END AS Risk,
			COUNT(DISTINCT SSN) AS COUNT
		FROM work.Master
		GROUP BY 
			Report_Month,
			calculated Risk;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I removed COUNT from the group by.&amp;nbsp; I added the keyword calculated before the variable RISK.&amp;nbsp; SAS needs an identifying keyword when you use a derived column/field/variable when it is built and used&amp;nbsp;within the same query.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 02:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-error/m-p/518294#M140262</guid>
      <dc:creator>ShiroAmada</dc:creator>
      <dc:date>2018-12-04T02:53:46Z</dc:date>
    </item>
  </channel>
</rss>

