<?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 in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368679#M64988</link>
    <description>&lt;P&gt;Please specify what the output should look like then, save, me trying to to guess. &amp;nbsp;If you want the names updated then something like:&lt;/P&gt;
&lt;PRE&gt;data ds;
  infile datalines;
  input id name $ age sex $ sal company $;
datalines;
111 abc 22 m 20000 infosys
121 xyz 32 m 21002 omega
131 def 63 m 41200 symprony
132 ekd 41 f 74100 infosys
474 ike 36 f 41200 omega
412 ier 36 f 32011 omega
;
run;

proc sql;
  create table WANT as
  select  cats(COMPANY," Total") as COMPANY,
          count(*) as TOTAL
  from    DS
  group by COMPANY
  union all 
  select  "Total",
          count(*) as TOTAL
  from    DS;
quit;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Jun 2017 12:05:45 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-06-20T12:05:45Z</dc:date>
    <item>
      <title>Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368580#M64979</link>
      <description>&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE WORK.NRI AS SELECT 'TOTAL' AS COUNTRY, SUM(ACCOUNTS_OPENED_LAST_MONTH) as ACCOUNTS_OPENED_LAST_MONTH,&lt;BR /&gt;sum(C2T_till_date_for_last_month) as C2T_till_date_for_last_month, (sum(C2T_till_date_for_last_month)/sum(ACCOUNTS_OPENED_LAST_MONTH))*100,&lt;BR /&gt;sum(Accounts_current_year) as Accounts_current_year, sum(Accounts_C2T_current_year) as Accounts_C2T_current_year,&lt;BR /&gt;(sum(Accounts_C2T_current_year)/sum(Accounts_current_year))*100, sum(New_Traders_today) as New_Traders_today,&lt;BR /&gt;sum(New_Traders_current_month) as New_Traders_current_month, 12 as sno from NRI_team,&lt;BR /&gt;group by( 1-sec , IBG )from Nri_team;&lt;BR /&gt;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;169 PROC SQL;&lt;BR /&gt;170 CREATE TABLE WORK.NRI AS SELECT 'TOTAL' AS COUNTRY, SUM(ACCOUNTS_OPENED_LAST_MONTH) as&lt;BR /&gt;170! ACCOUNTS_OPENED_LAST_MONTH,&lt;BR /&gt;171 sum(C2T_till_date_for_last_month) as C2T_till_date_for_last_month,&lt;BR /&gt;171! (sum(C2T_till_date_for_last_month)/sum(ACCOUNTS_OPENED_LAST_MONTH))*100,&lt;BR /&gt;172 sum(Accounts_current_year) as Accounts_current_year, sum(Accounts_C2T_current_year) as&lt;BR /&gt;172! Accounts_C2T_current_year,&lt;BR /&gt;173 (sum(Accounts_C2T_current_year)/sum(Accounts_current_year))*100, sum(New_Traders_today) as&lt;BR /&gt;173! New_Traders_today,&lt;BR /&gt;174 sum(New_Traders_current_month) as New_Traders_current_month, 12 as sno from NRI_team,&lt;BR /&gt;175 group by( 1-sec , IBG )from Nri_team;&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: GROUP, HAVING, ORDER, WHERE.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;176&lt;BR /&gt;177 quit;&lt;/P&gt;&lt;P&gt;it showig error ..for group by statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;plz rectify&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 05:48:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368580#M64979</guid>
      <dc:creator>vinod4842</dc:creator>
      <dc:date>2017-06-20T05:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368581#M64980</link>
      <description>&lt;P&gt;Remove the comma before the word GROUP.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should really really format your code. If makes it easier to see your errors.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're too lazy to do it yourself, highlight your code and press CTRL+ i in SAS EG&lt;/P&gt;
&lt;P&gt;or click the format button in SAS Studio. This is what I do &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 05:53:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368581#M64980</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-20T05:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368607#M64981</link>
      <description>data ds;&lt;BR /&gt;infile datalines;&lt;BR /&gt;input id name$ age sex$ sal company$;&lt;BR /&gt;datalines;&lt;BR /&gt;111 abc 22 m 20000 infosys&lt;BR /&gt;121 xyz 32 m 21002 omega&lt;BR /&gt;131 def 63 m 41200 symprony&lt;BR /&gt;132 ekd 41 f 74100 infosys&lt;BR /&gt;474 ike 36 f 41200 omega&lt;BR /&gt;412 ier 36 f 32011 omega&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table ds1 as select 'total' as id,name as name, sum(sal) as sal ,group by company from ds ;&lt;BR /&gt;run;&lt;BR /&gt;from this i want the company sub total and grand total in proc sql help me</description>
      <pubDate>Tue, 20 Jun 2017 07:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368607#M64981</guid>
      <dc:creator>vinod4842</dc:creator>
      <dc:date>2017-06-20T07:23:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368628#M64982</link>
      <description>&lt;P&gt;Its generally a good idea to start a new thread for new questions.&lt;/P&gt;
&lt;P&gt;You would need a union (or join if you want total on each row) as you can only group once in a select:&lt;/P&gt;
&lt;PRE&gt;data ds;
  infile datalines;
  input id name $ age sex $ sal company $;
datalines;
111 abc 22 m 20000 infosys
121 xyz 32 m 21002 omega
131 def 63 m 41200 symprony
132 ekd 41 f 74100 infosys
474 ike 36 f 41200 omega
412 ier 36 f 32011 omega
;
run;

proc sql;
  create table WANT as
  select  COMPANY,
          count(*) as TOTAL
  from    DS
  group by COMPANY
  union all 
  select  "Total",
          count(*) as TOTAL
  from    DS;
quit;&lt;/PRE&gt;
&lt;P&gt;Note the use of the code window (its the {i} above the post area) this retains code formatting which makes reading code easier.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 08:02:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368628#M64982</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-20T08:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368666#M64985</link>
      <description>&lt;P&gt;thank you very much but i am looking for the result of subtotal 'infosys total' , 'omega total' i,...........under the 'id' variable and sal subtotal &amp;nbsp;with other observation in and also grand total for this i am not getting..plz rectify&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 11:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368666#M64985</guid>
      <dc:creator>vinod4842</dc:creator>
      <dc:date>2017-06-20T11:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368679#M64988</link>
      <description>&lt;P&gt;Please specify what the output should look like then, save, me trying to to guess. &amp;nbsp;If you want the names updated then something like:&lt;/P&gt;
&lt;PRE&gt;data ds;
  infile datalines;
  input id name $ age sex $ sal company $;
datalines;
111 abc 22 m 20000 infosys
121 xyz 32 m 21002 omega
131 def 63 m 41200 symprony
132 ekd 41 f 74100 infosys
474 ike 36 f 41200 omega
412 ier 36 f 32011 omega
;
run;

proc sql;
  create table WANT as
  select  cats(COMPANY," Total") as COMPANY,
          count(*) as TOTAL
  from    DS
  group by COMPANY
  union all 
  select  "Total",
          count(*) as TOTAL
  from    DS;
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Jun 2017 12:05:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368679#M64988</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-06-20T12:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368714#M64995</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/144104"&gt;@vinod4842&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;thank you very much but i am looking for the result of subtotal 'infosys total' , 'omega total' i,...........under the 'id' variable and sal subtotal &amp;nbsp;with other observation in and also grand total for this i am not getting..plz rectify&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use a reporting procedure such as PROC REPORT not SQL for this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 13:55:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql/m-p/368714#M64995</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-20T13:55:13Z</dc:date>
    </item>
  </channel>
</rss>

