<?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 the difference of one variable between current year and last year. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525850#M143102</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Year      GVKEY   $          total_pps       ;
cards;
1992      001045            50                  *
1993       001045           56                  6
1994       001045           99                  43
1995       001045           69                  -30
1996       001045           78                  9
1997       001045            88                 10
;

data want;
set have;
by gvkey year;
dif=dif(total_pps);
if first.gvkey then call missing(dif);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Jan 2019 20:21:31 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-01-09T20:21:31Z</dc:date>
    <item>
      <title>Calculate the difference of one variable between current year and last year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525838#M143096</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have the annual data for one variable ("total_pps") for each company(labeled as "GVKEY"), and I'd like to calculate the difference between current year's "pps" and the pps for the last&amp;nbsp;year for each company and make it as current year's difference. For example, for gvkey=001045, the difference between pps in 1993 and pps in 1992 should be the "diff_pps" for 1993 which will become a new variable. How to write the codes?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a lot!!! And I attach a screencut of my data.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="微信图片_20190109144939.png" style="width: 339px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/26142iD6D192396258BB0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="微信图片_20190109144939.png" alt="微信图片_20190109144939.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 19:54:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525838#M143096</guid>
      <dc:creator>ADou</dc:creator>
      <dc:date>2019-01-09T19:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference of one variable between current year and last year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525840#M143097</link>
      <description>&lt;P&gt;Can you paste the date as text rather than pics plz . Also post a sample of your expected output plz&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 19:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525840#M143097</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-09T19:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference of one variable between current year and last year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525848#M143100</link>
      <description>&lt;P&gt;Sure. The attached is my expected output sample. Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 20:18:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525848#M143100</guid>
      <dc:creator>ADou</dc:creator>
      <dc:date>2019-01-09T20:18:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference of one variable between current year and last year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525850#M143102</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input Year      GVKEY   $          total_pps       ;
cards;
1992      001045            50                  *
1993       001045           56                  6
1994       001045           99                  43
1995       001045           69                  -30
1996       001045           78                  9
1997       001045            88                 10
;

data want;
set have;
by gvkey year;
dif=dif(total_pps);
if first.gvkey then call missing(dif);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Jan 2019 20:21:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525850#M143102</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-09T20:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference of one variable between current year and last year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525875#M143109</link>
      <description>&lt;P&gt;Thanks a lot!! It works well!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 20:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525875#M143109</guid>
      <dc:creator>ADou</dc:creator>
      <dc:date>2019-01-09T20:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference of one variable between current year and last year.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525902#M143114</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252730"&gt;@ADou&lt;/a&gt;&amp;nbsp; Can you acknowledge the answer by marking as accepted and close the thread?&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 21:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-the-difference-of-one-variable-between-current-year/m-p/525902#M143114</guid>
      <dc:creator>Allaluiah</dc:creator>
      <dc:date>2019-01-09T21:49:50Z</dc:date>
    </item>
  </channel>
</rss>

