<?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 Need Solution in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-Solution/m-p/524983#M142808</link>
    <description>&lt;P&gt;In the below picture, TABLE A has brand and then first.brand loan row contains total.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am want to do is create a desired table where the (first.brand row value = first row current value – following rows value ) and if its not the first.brand then value as the current value as show in the table 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="table.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26033iC6DE74D301FB23D2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="table.png" alt="table.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;BMW&lt;/P&gt;</description>
    <pubDate>Mon, 07 Jan 2019 07:56:57 GMT</pubDate>
    <dc:creator>Guptashwe</dc:creator>
    <dc:date>2019-01-07T07:56:57Z</dc:date>
    <item>
      <title>Need Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Solution/m-p/524983#M142808</link>
      <description>&lt;P&gt;In the below picture, TABLE A has brand and then first.brand loan row contains total.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am want to do is create a desired table where the (first.brand row value = first row current value – following rows value ) and if its not the first.brand then value as the current value as show in the table 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="table.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26033iC6DE74D301FB23D2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="table.png" alt="table.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;BMW&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 07:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Solution/m-p/524983#M142808</guid>
      <dc:creator>Guptashwe</dc:creator>
      <dc:date>2019-01-07T07:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Solution/m-p/525001#M142817</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class=""&gt;&lt;A id="link_8" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://communities.sas.com/t5/user/viewprofilepage/user-id/249630" target="_self"&gt;Guptashwe&lt;/A&gt;,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;You could do the following:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines;
	input id brand $ loan;
	return;
	datalines;
1 mini 70
2 mini 30
3 mini 20
4 mini 10
5 toyota 80
6 toyota 40
;
run;

proc sql;
	create table have2 as
		select id, brand, loan, sum(loan) as loan_calc
			from have 
				group by brand;
quit;

proc sort
	data= have2;
	by id;
run;

data want;
	set have2;
	by brand;

	if first.brand then
		loan_calc = loan-(loan_calc-loan);
	else loan_calc = loan;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 11:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Solution/m-p/525001#M142817</guid>
      <dc:creator>DJongman</dc:creator>
      <dc:date>2019-01-07T11:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Need Solution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-Solution/m-p/525039#M142836</link>
      <description>&lt;P&gt;Given your data are grouped by brand, this is a classic double DOW task in the data step. Read a group once to calculate the needed value.&amp;nbsp; Re-read the group using that&amp;nbsp; value an outputting the data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines;
	input id brand $ loan;
	return;
	datalines;
1 mini 70
2 mini 30
3 mini 20
4 mini 10
5 toyota 80
6 toyota 40
;
run;

data want (drop=_:);
  do until (last.brand);
    set have;
    by brand;
    if _loan=. then _loan=loan;
    else _loan=_loan-loan;
  end;
  do until (last.brand);
    set have;
    by brand;
    if _loan^=. then loan=_loan;
    output;
    _loan=.;
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-Solution/m-p/525039#M142836</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-01-07T14:36:47Z</dc:date>
    </item>
  </channel>
</rss>

