<?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: How to subtract two numeric values in same table different columns? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842544#M333157</link>
    <description>&lt;P&gt;Coding will be much easier if you use NORMAL variable names.&lt;/P&gt;
&lt;P&gt;So if you want the TRANSPOSE step this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TRANSPOSE DATA = YOY prefix=YEAR_ 
  OUT= OUTPUT (drop=_name_ rename=('Submitt Date'n=Submit_Date ))&lt;BR /&gt;;
  BY  'Submitt Date'n ;
  ID  Year;
   var AEP_Sales;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then OUTPUT will the variables SUBMIT_DATE YEAR_2021 YEAR_2022 etc instead of the goofy names that are causing you so much trouble.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2022 17:29:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-04T17:29:51Z</dc:date>
    <item>
      <title>How to subtract two numeric values in same table different columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842506#M333138</link>
      <description>&lt;P&gt;Good monring, I am trying to subtract two numeric variables (visual is below my code )from two columns, then get the percentage in another column. I want to create a column with the difference, then another column with the percentage differernce. Can someone please look at my code and tell me how to solve for this? I am getting the same answers for all rows, i added the group by and that didn't correct it.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TRANSPOSE DATA = YOY OUT= OUTPUT (drop=_name_);
BY  'Submitt Date'n ;
ID  Year;
var AEP_Sales
;RUN;

Proc sql; create table AEP_Compare as
select distinct *,
sum(2021-2022) as Difference
From Output
group by 'Submitt Date'n
;quit;

Proc sql; create table AEP_CompareF as
select distinct *,
Difference/2021 as'Percentage Difference'n 
From AEP_Compare
group by 'Submitt Date'n
;quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMSSAS_0-1667570309826.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/76942i1709E0DE962FE119/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LMSSAS_0-1667570309826.png" alt="LMSSAS_0-1667570309826.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 14:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842506#M333138</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-11-04T14:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two numeric values in same table different columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842520#M333142</link>
      <description>&lt;P&gt;Please disregard my original question. i was able to solve for this using, it was formatting issues.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql; create table AEP_Compare as
select distinct *,
'2021'n-'2022'n as Difference,
('2021'n-'2022'n)/'2021'n as'Percentage Difference'n
From Output
group by 'Submitt Date'n,'2021'n, '2022'n
;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Nov 2022 14:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842520#M333142</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-11-04T14:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two numeric values in same table different columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842521#M333143</link>
      <description>&lt;P&gt;You have told the Sum function to "sum" the value 2021-2022, which is ALWAYS -1. SAS doesn't use variable names like 2021. Non-standard names must use the '2021'n nomenclature, just like your 'Submitt date'n.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 14:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842521#M333143</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-04T14:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two numeric values in same table different columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842541#M333156</link>
      <description>Thank you!</description>
      <pubDate>Fri, 04 Nov 2022 16:56:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842541#M333156</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-11-04T16:56:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract two numeric values in same table different columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842544#M333157</link>
      <description>&lt;P&gt;Coding will be much easier if you use NORMAL variable names.&lt;/P&gt;
&lt;P&gt;So if you want the TRANSPOSE step this way:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC TRANSPOSE DATA = YOY prefix=YEAR_ 
  OUT= OUTPUT (drop=_name_ rename=('Submitt Date'n=Submit_Date ))&lt;BR /&gt;;
  BY  'Submitt Date'n ;
  ID  Year;
   var AEP_Sales;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then OUTPUT will the variables SUBMIT_DATE YEAR_2021 YEAR_2022 etc instead of the goofy names that are causing you so much trouble.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2022 17:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-subtract-two-numeric-values-in-same-table-different/m-p/842544#M333157</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-04T17:29:51Z</dc:date>
    </item>
  </channel>
</rss>

