<?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: calculate difference between two lists of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443301#M110891</link>
    <description>&lt;P&gt;Right, but my question is how to do that using macro? I have 600 variables.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Mar 2018 13:59:19 GMT</pubDate>
    <dc:creator>garfield83</dc:creator>
    <dc:date>2018-03-07T13:59:19Z</dc:date>
    <item>
      <title>calculate difference between two lists of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443019#M110804</link>
      <description>&lt;P&gt;I have two list of variables, they are the same metrics, but from different point of time, right now I want to calculate the difference between them, the dataset looks like this:&lt;/P&gt;&lt;P&gt;account fico_201701 beacon_201701 dpd_201701 fico_201712 beacon_201712 dpd_201712&lt;/P&gt;&lt;P&gt;I want to calculate difference between fico_201701 and fico_201712/ beacon_201701 and beacon_201712 and etc, how do I program for it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 20:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443019#M110804</guid>
      <dc:creator>garfield83</dc:creator>
      <dc:date>2018-03-06T20:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: calculate difference between two lists of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443025#M110808</link>
      <description>&lt;P&gt;Are you joining two tables into one and trying to get the difference between variables of alike ones.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like :&lt;/P&gt;&lt;P&gt;Table A : account fico_201701 beacon_201701 dpd_201701&lt;BR /&gt;Table B : account fico_201712 beacon_201712 dpd_201712&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Mar 2018 20:16:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443025#M110808</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-03-06T20:16:32Z</dc:date>
    </item>
    <item>
      <title>Re: calculate difference between two lists of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443163#M110847</link>
      <description>&lt;P&gt;Exactly right&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 02:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443163#M110847</guid>
      <dc:creator>garfield83</dc:creator>
      <dc:date>2018-03-07T02:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: calculate difference between two lists of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443168#M110850</link>
      <description>1. Sort the 2 datasets by account.&lt;BR /&gt;2. Merge the 2 datasets to create a single dataset by account.&lt;BR /&gt;3. In the Merge step subtract the related variables to get your result.&lt;BR /&gt;e.g. fico_diff=fico_201701-fico_201712</description>
      <pubDate>Wed, 07 Mar 2018 04:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443168#M110850</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-03-07T04:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: calculate difference between two lists of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443200#M110862</link>
      <description>&lt;P&gt;I would start by fixing the input datasets so that they have a date-variable containing the postfix of the other variables, thus you can store the data of any time point in on dataset. For the calculation you need the data sorted by account and date, then you can use the dif-function to get the differences.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 07:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443200#M110862</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-03-07T07:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: calculate difference between two lists of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443301#M110891</link>
      <description>&lt;P&gt;Right, but my question is how to do that using macro? I have 600 variables.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 13:59:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443301#M110891</guid>
      <dc:creator>garfield83</dc:creator>
      <dc:date>2018-03-07T13:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: calculate difference between two lists of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443312#M110897</link>
      <description>&lt;P&gt;Maybe my eyes need to checked by a doc, but i can't see anything about having 600 vars in your starting post. Using an array with a simple loop seems to be appropriate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested fragment:&lt;/P&gt;
&lt;PRE&gt;data work.want;
	set have;
	by account;

	array vars fico beacon dpd ...;
	array diffs fico_diff beacon_diff dpd_diff ...;

	do i = 1 to dim(vars);
		diffs[i] = lag(vars[i]);
		if first.account then do;
			diffs[i] = 0;
		end;
	end;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Mar 2018 14:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-difference-between-two-lists-of-variables/m-p/443312#M110897</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-03-07T14:18:04Z</dc:date>
    </item>
  </channel>
</rss>

