<?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 sum and group by in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sum-and-group-by/m-p/857527#M338831</link>
    <description>&lt;P&gt;Hi, i have extracted characters(from 6th character till the last one) from numeric variable(account_number) and stored the results in new variable Acct_no from below logic, after that i did summation of trns_amt &amp;amp; trns_volume variables and grouped by the new variable&amp;nbsp;Acct_no .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;before using substring i had 16 digits on account_number variable(e,g 4000061234567890) and my new variable&amp;nbsp;Acct_no had the result&amp;nbsp;61234567890 which is what i wanted.&lt;/P&gt;
&lt;P&gt;Now i am having an issue on my summary data, the variable&amp;nbsp;Acct_no excludes the first digit(which is 6 in this instance), for example it returns(1234567890) and omit 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table acct_extract as
   select *,
       SUBSTR(put(CH_ACCT_NO,best32.-L),6) as Acct_no
   from ccpos_trns
;quit;

PROC SQL ;
 create table credit_total_spnt as
 select Acct_no,
        sum(TRNS_AMT) as Total_Amt,
		sum(TRNS_VOLUME) as Total_Trns
 from acct_extract
 group by Acct_no
 ;quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2023 11:35:24 GMT</pubDate>
    <dc:creator>Solly7</dc:creator>
    <dc:date>2023-02-07T11:35:24Z</dc:date>
    <item>
      <title>sum and group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-and-group-by/m-p/857527#M338831</link>
      <description>&lt;P&gt;Hi, i have extracted characters(from 6th character till the last one) from numeric variable(account_number) and stored the results in new variable Acct_no from below logic, after that i did summation of trns_amt &amp;amp; trns_volume variables and grouped by the new variable&amp;nbsp;Acct_no .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;before using substring i had 16 digits on account_number variable(e,g 4000061234567890) and my new variable&amp;nbsp;Acct_no had the result&amp;nbsp;61234567890 which is what i wanted.&lt;/P&gt;
&lt;P&gt;Now i am having an issue on my summary data, the variable&amp;nbsp;Acct_no excludes the first digit(which is 6 in this instance), for example it returns(1234567890) and omit 6&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table acct_extract as
   select *,
       SUBSTR(put(CH_ACCT_NO,best32.-L),6) as Acct_no
   from ccpos_trns
;quit;

PROC SQL ;
 create table credit_total_spnt as
 select Acct_no,
        sum(TRNS_AMT) as Total_Amt,
		sum(TRNS_VOLUME) as Total_Trns
 from acct_extract
 group by Acct_no
 ;quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 11:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-and-group-by/m-p/857527#M338831</guid>
      <dc:creator>Solly7</dc:creator>
      <dc:date>2023-02-07T11:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: sum and group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-and-group-by/m-p/857533#M338832</link>
      <description>&lt;P&gt;I can't duplicate your problem. Please provide a portion of your real data which illustrates the problem, as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;Instructions&lt;/A&gt;), and not in any other format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    CH_ACCT_NO=4000061234567890;
    trns_amt=7;
    trns_volume=120;
run;

proc sql;
   create table acct_extract as
   select *,
       SUBSTR(put(CH_ACCT_NO,best32.-L),6) as Acct_no
   from have
;quit;

PROC SQL ;
 create table credit_total_spnt as
 select Acct_no,
        sum(TRNS_AMT) as Total_Amt,
		sum(TRNS_VOLUME) as Total_Trns
 from acct_extract
 group by Acct_no
 ;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 12:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-and-group-by/m-p/857533#M338832</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-07T12:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: sum and group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sum-and-group-by/m-p/857618#M338874</link>
      <description>&lt;P&gt;If CH_ACCT_NO is stored as a number, this needs to be rectified first, at the point where the data is read into the SAS environment. Account "numbers" are not numbers used for calculations, they are just codes, which m7st be stored as character. In the moment they exceed 15 decimal digits, the limits of numerical precision will kick in and lead to unpredictable and wrong results.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2023 17:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sum-and-group-by/m-p/857618#M338874</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-02-07T17:47:44Z</dc:date>
    </item>
  </channel>
</rss>

