<?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 several variables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933777#M44901</link>
    <description>&lt;P&gt;Several variables suggest an array might be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
   input id Y23Jan Y23Feb Y23Mar Y24Jan Y24Feb Y24Mar;
   Array _23 Y23:;
   array _24 Y24:;
   array _df Dif1-Dif3;
   do over _23;
      _df = _24-_23;
      end;
   datalines;
1 0.54 0.54 0.52 0.62 0.61 0.60
2 0.48 0.45 0.48 0.71 0.68 0.67
3 0.59 0.61 0.59 0.57 0.54 0.58
4 0.61 0.62 0.59 0.62 0.61 0.54
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 464px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97897iF63C4CA73FA20637/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2024 12:25:18 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2024-06-26T12:25:18Z</dc:date>
    <item>
      <title>Calculate difference between several variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933774#M44900</link>
      <description>&lt;P&gt;Hello, I am trying to calculate the difference between the data observed in 2023 and 2024 by month.&amp;nbsp; I have a total of 84 observations and need to calculate the difference between all 12 months. Below is a sample of how the data is formatted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;data Have;
    input id 23Jan 23Feb 23Mar 24Jan 24Feb 24Mar;
      datalines;
1 0.54 0.54 0.52 0.62 0.61 0.60
2 0.48 0.45 0.48 0.71 0.68 0.67
3 0.59 0.61 0.59 0.57 0.54 0.58
4 0.61 0.62 0.59 0.62 0.61 0.54
;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;I want a dataset that contains the difference for each month for all 84 observations.&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;Data Want;
ID JanDiff FebDiff MarDiff
1
2
3
4&lt;/LI-CODE&gt;&lt;P&gt;I know I can write out all 12 calculations but is their a more efficient coding strategy to calculate the differences?&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 11:59:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933774#M44900</guid>
      <dc:creator>OlsabeckT29</dc:creator>
      <dc:date>2024-06-26T11:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between several variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933777#M44901</link>
      <description>&lt;P&gt;Several variables suggest an array might be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
   input id Y23Jan Y23Feb Y23Mar Y24Jan Y24Feb Y24Mar;
   Array _23 Y23:;
   array _24 Y24:;
   array _df Dif1-Dif3;
   do over _23;
      _df = _24-_23;
      end;
   datalines;
1 0.54 0.54 0.52 0.62 0.61 0.60
2 0.48 0.45 0.48 0.71 0.68 0.67
3 0.59 0.61 0.59 0.57 0.54 0.58
4 0.61 0.62 0.59 0.62 0.61 0.54
;;;;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 464px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/97897iF63C4CA73FA20637/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 12:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933777#M44901</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2024-06-26T12:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between several variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933783#M44903</link>
      <description>&lt;P&gt;Are there ever more than two years for January? Are there ever more than two years for other months? What would we do then?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 13:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933783#M44903</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-06-26T13:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate difference between several variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933784#M44904</link>
      <description>No, we are only looking at the difference between two years.&lt;BR /&gt;</description>
      <pubDate>Wed, 26 Jun 2024 13:37:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Calculate-difference-between-several-variables/m-p/933784#M44904</guid>
      <dc:creator>OlsabeckT29</dc:creator>
      <dc:date>2024-06-26T13:37:18Z</dc:date>
    </item>
  </channel>
</rss>

