<?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: percentage change in value over multiple years for different firms in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500573#M371</link>
    <description>&lt;P&gt;I think you may have&amp;nbsp;missed the part about what you need as output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Oct 2018 21:48:31 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-10-01T21:48:31Z</dc:date>
    <item>
      <title>percentage change in value over multiple years for different firms</title>
      <link>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500544#M365</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sample data.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23679i0C9991F3CD30616D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Sample data.PNG" alt="Sample data.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data growth;&lt;BR /&gt;input firm sales year&lt;/P&gt;&lt;P&gt;datalines;&lt;BR /&gt;A 2400 2001&lt;BR /&gt;A 2500 2002&lt;BR /&gt;A 2600 2003&lt;BR /&gt;A 2700 2004&lt;BR /&gt;A 2800 2005&lt;BR /&gt;B 1500 2001&lt;BR /&gt;B 1600 2002&lt;BR /&gt;B 1700 2003&lt;BR /&gt;B 1800 2004&lt;BR /&gt;B 1900 2005&lt;BR /&gt;C 3100 2001&lt;BR /&gt;C 3200 2002&lt;BR /&gt;C 3300 2003&lt;BR /&gt;C 3400 2004&lt;BR /&gt;C 3400 2005&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;I need 3 output column under&amp;nbsp; &amp;nbsp;growth_in_1yr&amp;nbsp; , growth_in_2yrs&amp;nbsp; &amp;nbsp;&amp;amp;&amp;nbsp; growth_in_3yrs&lt;BR /&gt;&amp;nbsp; for percentage change in sales&amp;nbsp;over 1,2 and 3 years for each firm and each year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;in other words, how much the sales changed(%) in 1 yr , 2 yr &amp;amp; 3 yr in separate column for each firm on each year.&lt;/P&gt;&lt;P&gt;But the problem is data always overlaps with other firms. I am new in SAS and programming. So its really confusing for me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 22:19:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500544#M365</guid>
      <dc:creator>Takdir</dc:creator>
      <dc:date>2018-10-01T22:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: percentage change in value over multiple years for different firms</title>
      <link>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500547#M366</link>
      <description>&lt;P&gt;Ok, That's what you have. What do you want as output? Please post your data as text, not images. Otherwise to work with it we need to type it in, and that's a lot less people who will then work on your problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 20:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500547#M366</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-01T20:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: percentage change in value over multiple years for different firms</title>
      <link>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500548#M367</link>
      <description>&lt;P&gt;i edited the post. is it better now ?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 20:32:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500548#M367</guid>
      <dc:creator>Takdir</dc:creator>
      <dc:date>2018-10-01T20:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: percentage change in value over multiple years for different firms</title>
      <link>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500573#M371</link>
      <description>&lt;P&gt;I think you may have&amp;nbsp;missed the part about what you need as output?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 21:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500573#M371</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-01T21:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: percentage change in value over multiple years for different firms</title>
      <link>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500591#M377</link>
      <description>&lt;P&gt;See if this gets you started;&lt;/P&gt;
&lt;PRE&gt;data work.growth;
input firm $ sales year;
datalines;
A 2400 2001
A 2500 2002
A 2600 2003
A 2700 2004
A 2800 2005
B 1500 2001
B 1600 2002
B 1700 2003
B 1800 2004
B 1900 2005
C 3100 2001
C 3200 2002
C 3300 2003
C 3400 2004
C 3400 2005
;

data want;
   set work.growth;
   by firm;
   lyr1 = lag1(sales);
   lyr2 = lag2(sales);
   lyr3 = lag3(sales);
   if first.firm then count=0;
   else count+1;
   if count ge 1 then growth1yr = (sales - lyr1)/lyr1;
   if count ge 2 then growth2yr = (sales - lyr2)/lyr2;
   if count ge 3 then growth3yr = (sales - lyr3)/lyr3;
run;

&lt;/PRE&gt;
&lt;P&gt;This assumes that you data is sorted by FIRM and YEAR. Note the changes to your data step code to remove the errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LAG is a function to look at a previous value. The COUNT variable is reset each time the firm changes and indicates how many previous years may be available for use. I left the LYR1 etc variables in the data so you could see which ones are used in calculations.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 17:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/percentage-change-in-value-over-multiple-years-for-different/m-p/500591#M377</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-03T17:15:49Z</dc:date>
    </item>
  </channel>
</rss>

