<?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: Create net columns by day and customer - arrays in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701578#M214850</link>
    <description>&lt;P&gt;Using words and/or plain math formulae, how do you want to compute&amp;nbsp;CreditNet, DebitNet, BalanceNet, and AmountArrearsNet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Nov 2020 16:40:35 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-11-25T16:40:35Z</dc:date>
    <item>
      <title>Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701571#M214844</link>
      <description>&lt;P&gt;Hello! I need to create in SAS net columns of other columns group by day and customer. I don´t know how to use information data that is previous, maybe it will be useful with arrays.. but I don´t know accuracy the method.&lt;/P&gt;
&lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
infile datalines dsd delimiter=',';
informat Effective_date1 ddmmyy10.;
format Effective_date1  ddmmyy10.;
input Agreement	Customer	Effective_date1	Credit	Debit	Balance AmountArrears;
datalines;
1,0,01/01/2020,100,0,10000,100,			
2,0,02/01/2020,0,10,500,10,			
1,0,03/02/2020,0,50,10000,50,			
2,0,03/02/2020,0,10,490,20,			
1,0,05/02/2020,50,0,9950,0,			
2,0,05/02/2020,0,10,480,30,			
1,0,08/02/2020,0,30,9920,30,			
2,0,08/02/2020,30,0,450,0,			

;;;;
RUN;

DATA want;
infile datalines dsd delimiter=',';
informat Effective_date1 ddmmyy10.;
format Effective_date1  ddmmyy10.;
input Agreement	Customer Effective_date1 Credit	Debit Balance AmountArrears CreditNet	DebitNet	BalanceNet AmountArrearsNet	;
datalines;
1,0,01/01/2020,100,0,10000,0,100,0,10000,0,			
2,0,02/01/2020,0,10,500,10,0,10,500,10,		
1,0,03/02/2020,0,50,10000,50,0,60,10490,70,			
2,0,03/02/2020,0,10,490,20,0,60,10490,70,			
1,0,05/02/2020,50,0,9950,0,50,10,10430,30,		
2,0,05/02/2020,0,10,480,30,50,10,10430,30,			
1,0,08/02/2020,0,30,9920,30,30,30,10370,30,			
2,0,08/02/2020,30,0,450,0,30,30,10370,30,			

;;;;
RUN;






			&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701571#M214844</guid>
      <dc:creator>t34</dc:creator>
      <dc:date>2020-11-25T18:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701578#M214850</link>
      <description>&lt;P&gt;Using words and/or plain math formulae, how do you want to compute&amp;nbsp;CreditNet, DebitNet, BalanceNet, and AmountArrearsNet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701578#M214850</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-25T16:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701587#M214853</link>
      <description>Sum the values of each column for same customer and same day</description>
      <pubDate>Wed, 25 Nov 2020 16:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701587#M214853</guid>
      <dc:creator>t34</dc:creator>
      <dc:date>2020-11-25T16:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701588#M214854</link>
      <description>&lt;P&gt;One of the functions available is SAS is the LAG function that allows you to get values from previous records (carefully conditions do not work as you might expect).&lt;/P&gt;
&lt;P&gt;Here is a short demo of the generic approach I think you may be looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
   input customer $ value;
datalines;
A   123
A   456
A   3
B   44
B   22
;

data want;
   set have;
   by customer;
   lastvalue= lag(value);
   if first.customer then newvalue=.;
   else newvalue = sum(value, lastvalue);
run;&lt;/PRE&gt;
&lt;P&gt;You could drop the lastvalue variable but I left it in to show what happens.&lt;/P&gt;
&lt;P&gt;You would likely need several "last" variables to keep track and the first.customer likely needs a " then do; end; " with several variables initialized to either 0 or missing as desired.&lt;/P&gt;
&lt;P&gt;You would need to make sure the data is sorted by customer and date if it isn't already.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701588#M214854</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-25T16:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701589#M214855</link>
      <description>Thanks a lot for your answer!!!&lt;BR /&gt;The problem is that in the real table- on same day, there are 3, 4 or... n transactions</description>
      <pubDate>Wed, 25 Nov 2020 16:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701589#M214855</guid>
      <dc:creator>t34</dc:creator>
      <dc:date>2020-11-25T16:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701595#M214859</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344580"&gt;@t34&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks a lot for your answer!!!&lt;BR /&gt;The problem is that in the real table- on same day, there are 3, 4 or... n transactions&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the problem with my example is what exactly?&lt;/P&gt;
&lt;P&gt;You didn't provide any actual description of what calculation is needed. I show how to use previous value for a calculation with the option of resetting when a key value changes.&lt;/P&gt;
&lt;P&gt;Try it with ONE variable and see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If AGREEMENT has any role in the problem you really need to describe it as well.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 17:03:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701595#M214859</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-25T17:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701623#M214867</link>
      <description>First,apologies for the explanation&lt;BR /&gt;A customer can have several agreeements&lt;BR /&gt;I need the net value for each day by agreement in every row.&lt;BR /&gt;Os in your example (without date) , I need the value 459 for every A and 66 for every B&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Nov 2020 17:51:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701623#M214867</guid>
      <dc:creator>t34</dc:creator>
      <dc:date>2020-11-25T17:51:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701630#M214870</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344580"&gt;@t34&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;First,apologies for the explanation&lt;BR /&gt;A customer can have several agreeements&lt;BR /&gt;I need the net value for each day by agreement in every row.&lt;BR /&gt;Os in your example (without date) , I need the value 459 for every A and 66 for every B&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So&amp;nbsp; still waiting for definitions of how to get the "net" anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701630#M214870</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-25T18:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701639#M214873</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each customer and effective_date&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;NetCredit= sum of values of credits of the same day and effective day&lt;/LI&gt;
&lt;LI&gt;NetDebit= sum of values of debits of the same day and effective day&lt;/LI&gt;
&lt;LI&gt;NetAmountArrears= sum of values of amount arrearsof the same day and effective day&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;When there are records in the same day, all net columns have to value the same in all records of these days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If effective_date are differents for each customer&lt;/P&gt;
&lt;P&gt;amount_arrears = last_amount_arrears + cr - dr&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can forget about balance (it is not interested here)&lt;/P&gt;
&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701639#M214873</guid>
      <dc:creator>t34</dc:creator>
      <dc:date>2020-11-25T18:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701643#M214876</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/344580"&gt;@t34&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For each customer and effective_date&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;NetCredit= sum of values of credits of the same day and effective day&lt;/LI&gt;
&lt;LI&gt;NetDebit= sum of values of debits of the same day and effective day&lt;/LI&gt;
&lt;LI&gt;NetAmountArrears= sum of values of amount arrearsof the same day and effective day&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;When there are records in the same day, all net columns have to value the same in all records of these days.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have one date value. So what is the difference between "same day" and "effective day"? The way you phrase that there should be another variable involved. Please phrase things in terms of VARIABLES.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701643#M214876</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-25T18:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create net columns by day and customer - arrays</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701699#M214894</link>
      <description>I mean "same day" when a record has got the equal Effective_date1  than other record</description>
      <pubDate>Wed, 25 Nov 2020 21:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-net-columns-by-day-and-customer-arrays/m-p/701699#M214894</guid>
      <dc:creator>t34</dc:creator>
      <dc:date>2020-11-25T21:23:08Z</dc:date>
    </item>
  </channel>
</rss>

