<?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 sum a column per variable that changes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836046#M330577</link>
    <description>&lt;P&gt;So the step is to change 0202 under SECOND_ID to 0101? That's the only change? Or is it more general than that where sometimes 0404 change to 0101 as well? Or 3333 changes to 0237?&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2022 11:58:55 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-09-30T11:58:55Z</dc:date>
    <item>
      <title>how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/835991#M330541</link>
      <description>&lt;P&gt;I am quite a novice in programming and I kind need your help regarding an issue I notice.&lt;/P&gt;&lt;P&gt;I have a table:&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE class=""&gt;&lt;SPAN class=""&gt;date&lt;/SPAN&gt;  ID  secondary  D  E
date1 b1   c1          d1 e1
date1 b    c           d  e
date3 b2   c1          d3 e3
date4 b2   c2          d4 e4&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Id and secondary should be unique and always matching. But I notice that they are not. It's either correct the ID or the secondary ID. I want to sum all the D column per unique ID. Thanks you all for reading and if you have any inputs would be very helpful&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 04:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/835991#M330541</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T04:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/835996#M330544</link>
      <description>&lt;P&gt;The statemnt "BY ID secondary" is unique if the combination of the by variables is unique.&lt;/P&gt;
&lt;P&gt;In your example: 'b1 c1',&amp;nbsp; 'b2 c1',&amp;nbsp; 'b2 c2' - these are all unique values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to sum D column it should be numeric otherwise it has no sense;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 05:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/835996#M330544</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2022-09-30T05:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/835997#M330545</link>
      <description>&lt;P&gt;Here's how I interpret your question: In the first row, you want Id to equal Secondary. So you change either Id to 'c1' or Secondary to 'b1'. Then you do that for all obs, so that if ID = Secondary = 'b1' for example, then no other obs can have ID = 'b1' or Secondary = 'B1', correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't understand the summation of the D Columns though. Help me here?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 05:19:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/835997#M330545</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-30T05:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836007#M330552</link>
      <description>YESSS &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; ... correct thank you. And then I want to sum column d for each (unique) ID . Thank you PeterC</description>
      <pubDate>Fri, 30 Sep 2022 06:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836007#M330552</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T06:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836008#M330553</link>
      <description>&lt;P&gt;But D is a character column?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 06:39:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836008#M330553</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-09-30T06:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836010#M330554</link>
      <description>&lt;P&gt;no everything is numeric even ID. It's like this. As you can see we have different dates (but for the same date multiple customers). I notice that customer 258 for secondary ID 0004 during the years the ID or the secondary ID changes. And I wan to assign the same ID as the frist date and the same secondary ID as the first date ( or any day just to be cnsistent). I want to to do this cause I want to know how many expenses each customer has during the years. There are like 50m obs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;date,&amp;nbsp; &amp;nbsp; &amp;nbsp;        ID,        secondary ID,     expenses
jul2020           258           0004               1000
jul2020           xxx           xxxx                 xxx
......              ....               ....                 .....
......              ....               ....                   .....
aug2020         258             0008               2000
aug2020         xxx             xxxx                xxx
aug2020         500              0004             1000&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Sep 2022 06:53:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836010#M330554</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T06:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836014#M330555</link>
      <description>&lt;P&gt;If I understand you correctly you want to summarize the expences per user=ID.&lt;/P&gt;
&lt;P&gt;That can be done either by proc summary (or peoc means, same syntax):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have noprint;
  calss ID;   /* or ID secondary ? */
  var expenses;
  output out=want sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or by sql&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select id, 
        sum(expenses)
   from have
   group by ID;   /* or id, secodary */
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 07:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836014#M330555</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2022-09-30T07:35:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836015#M330556</link>
      <description>&lt;P&gt;yeah but if I do that and don't take into account that the ID for the same customer is changing for some months wouldn't I loose some sums?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 07:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836015#M330556</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T07:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836026#M330561</link>
      <description>&lt;P&gt;To summarize per ID per month you need to add the date with appropriate format to the class or by statemnet.&lt;/P&gt;
&lt;P&gt;Using proc summary it could be:&amp;nbsp;&lt;EM&gt;by ID date; format date yymmn6.;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 08:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836026#M330561</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2022-09-30T08:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836037#M330569</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/435229"&gt;@neo_noone&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am quite a novice in programming and I kind need your help regarding an issue I notice.&lt;/P&gt;
&lt;P&gt;I have a table:&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE class=""&gt;&lt;SPAN class=""&gt;date&lt;/SPAN&gt;  ID  secondary  D  E
date1 b1   c1          d1 e1
date1 b    c           d  e
date3 b2   c1          d3 e3
date4 b2   c2          d4 e4&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Id and secondary should be unique and always matching. But I notice that they are not. It's either correct the ID or the secondary ID. I want to sum all the D column per unique ID. Thanks you all for reading and if you have any inputs would be very helpful&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The table has zero numeric variables (except for date, maybe), so there seems to be nothing that can be summed. Please post the data you have in usable form (a data step using datalines) and show the expected output for that dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 10:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836037#M330569</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-30T10:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836041#M330573</link>
      <description>&lt;P&gt;&lt;SPAN&gt;no everything is numeric even ID. It's like this. As you can see we have different dates (but for the same date multiple customers). I notice that customer 258 for secondary ID 0004 during the years the ID or the secondary ID changes. And I wan to assign the same ID as the first&amp;nbsp;date and the same secondary ID as the first date ( or any day just to be consistent). I want to to do this cause I want to know how many expenses each customer has during the years. There are like 50m obs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE class=""&gt;&lt;SPAN class=""&gt;date&lt;/SPAN&gt;,             ID,        secondary ID,     expenses
jul2020           &lt;SPAN class=""&gt;258&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0004&lt;/SPAN&gt;               &lt;SPAN class=""&gt;1000&lt;/SPAN&gt;
jul2020           xxx           xxx               xxx
…        ….               ….              …..
aug2020         &lt;SPAN class=""&gt;258&lt;/SPAN&gt;             &lt;SPAN class=""&gt;0008&lt;/SPAN&gt;               &lt;SPAN class=""&gt;2000&lt;/SPAN&gt;
aug2020         xxx             xxx               xxx
aug2020         &lt;SPAN class=""&gt;500&lt;/SPAN&gt;             &lt;SPAN class=""&gt;0004&lt;/SPAN&gt;             &lt;SPAN class=""&gt;1000&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 11:14:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836041#M330573</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T11:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836043#M330574</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/435229"&gt;@neo_noone&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;no everything is numeric even ID. It's like this. As you can see we have different dates (but for the same date multiple customers). I notice that customer 258 for secondary ID 0004 during the years the ID or the secondary ID changes. And I wan to assign the same ID as the first&amp;nbsp;date and the same secondary ID as the first date ( or any day just to be consistent). I want to to do this cause I want to know how many expenses each customer has during the years. There are like 50m obs.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE class=""&gt;&lt;SPAN class=""&gt;date&lt;/SPAN&gt;,             ID,        secondary ID,     expenses
jul2020           &lt;SPAN class=""&gt;258&lt;/SPAN&gt;          &lt;SPAN class=""&gt;0004&lt;/SPAN&gt;               &lt;SPAN class=""&gt;1000&lt;/SPAN&gt;
jul2020           xxx           xxx               xxx
…        ….               ….              …..
aug2020         &lt;SPAN class=""&gt;258&lt;/SPAN&gt;             &lt;SPAN class=""&gt;0008&lt;/SPAN&gt;               &lt;SPAN class=""&gt;2000&lt;/SPAN&gt;
aug2020         xxx             xxx               xxx
aug2020         &lt;SPAN class=""&gt;500&lt;/SPAN&gt;             &lt;SPAN class=""&gt;0004&lt;/SPAN&gt;             &lt;SPAN class=""&gt;1000&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please fix this table, so that there are no xxx, there are actual numbers in the columns (even if you have to make up some numbers), and then show us the resulting table you want. Actually do the math for this small table, sum the columns and show us the desired output.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 11:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836043#M330574</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-30T11:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836045#M330576</link>
      <description>&lt;P&gt;thank you for trying&amp;nbsp;&lt;/P&gt;&lt;P&gt;lets say this is the original table&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;first_id&lt;/TD&gt;&lt;TD&gt;second_id&lt;/TD&gt;&lt;TD&gt;expenses&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;jul2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;jul2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aug2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0202&lt;/TD&gt;&lt;TD&gt;1500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aug2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sep2020&lt;/TD&gt;&lt;TD&gt;402&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;3200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sep2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;oct2020&lt;/TD&gt;&lt;TD&gt;403&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;oct2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;nov2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0202&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;nov2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If you notice customer 400 has second ID 0101. But during the years the first ID or the second ID changes (not both at the same time). I want the table to become something like that&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;first_id&lt;/TD&gt;&lt;TD&gt;second_id&lt;/TD&gt;&lt;TD&gt;expenses&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;jul2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;/TR&gt;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TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;now the customer with first ID 400 and second 0101 keeps it's original values thought the year.&lt;/P&gt;&lt;P&gt;After that I want to aggregate the expenses it by first ID ( I can do that) I just can't change the first ID or the second ID&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 11:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836045#M330576</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T11:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836046#M330577</link>
      <description>&lt;P&gt;So the step is to change 0202 under SECOND_ID to 0101? That's the only change? Or is it more general than that where sometimes 0404 change to 0101 as well? Or 3333 changes to 0237?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 11:58:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836046#M330577</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-30T11:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836048#M330578</link>
      <description>&lt;P&gt;YESSS and if the first ID is different than the original ( if it is, then the second ID will be the same as the original ID if you notice) change it to the original first ID&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 12:12:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836048#M330578</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T12:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836049#M330579</link>
      <description>&lt;P&gt;Okay what happened here? There was a response from you that showed a table in which 0202 was changed to 0101, and now it is gone. Did you do that or did the SAS Communities do that?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 12:17:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836049#M330579</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-30T12:17:33Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836050#M330580</link>
      <description>&lt;P&gt;Nope wasn't me. let me just update it&lt;/P&gt;&lt;P&gt;original&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;first_id&lt;/TD&gt;&lt;TD&gt;second_id&lt;/TD&gt;&lt;TD&gt;expenses&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;jul2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;1000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;jul2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aug2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0202&lt;/TD&gt;&lt;TD&gt;1500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aug2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sep2020&lt;/TD&gt;&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TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aug2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;1500&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;aug2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sep2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;3200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;sep2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;oct2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;oct2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;nov2020&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;0101&lt;/TD&gt;&lt;TD&gt;100&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;nov2020&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;TD&gt;89&lt;/TD&gt;&lt;TD&gt;2001&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 30 Sep 2022 12:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836050#M330580</guid>
      <dc:creator>neo_noone</dc:creator>
      <dc:date>2022-09-30T12:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to sum a column per variable that changes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836051#M330581</link>
      <description>&lt;P&gt;how about this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
input date :monyy7.	first_id $	second_id $	expenses;
format date monyy7.;
cards;
jul2020	400	0101 1000
jul2020	500	89 2001
aug2020	400	0202 1500
aug2020	500	89 2001
sep2020	402	0101 3200
sep2020	500	89 2001
oct2020	403	0101 200
oct2020	500	89 2001
nov2020	400	0202 100
nov2020	500	89 2001
;
proc sort data=have;
    by first_id date;
run;
data want;
    set have;
    by first_id;
    retain second_id1;
    if first.first_id then second_id1=second_id;
    drop second_id;
run;
proc sort data=want;
    by date first_id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;although I'm still not sure about your question about sums, what sums do you want from this table? Please show me. (Also, why does second_id even matter?)&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 12:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-sum-a-column-per-variable-that-changes/m-p/836051#M330581</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-30T12:37:39Z</dc:date>
    </item>
  </channel>
</rss>

