<?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: Displaying percentage change over time in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116732#M32188</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You already have two useful suggestions but, since you are learning SAS, I decided to throw in one more that does everything in one simple datastep.&amp;nbsp; Is there any reason why you enter year as a character variable?&amp;nbsp; In the following, I enter the years as numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new (keep=year2008-year2012 Avg);&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines dlm=',' dsd eof=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array gr_array(2008:2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array ug_array(2008:2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array year_array(2008:2012) year2008-year2012;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format year2008-year2012 Avg percent8.2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain gr_array ug_array;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input year gr_count ug_count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; gr_array(year)=gr_count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ug_array(year)=ug_count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; year_array(year)=year;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return;&lt;/P&gt;&lt;P&gt;&amp;nbsp; last:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do year=2009 to 2012;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year_array(year)=gr_array(year)/gr_array(year-1)-1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Avg=mean(of Year2008-Year2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;2008,5045,7420&lt;/P&gt;&lt;P&gt;2009,5500,7837&lt;/P&gt;&lt;P&gt;2010,5696,8481&lt;/P&gt;&lt;P&gt;2011,5708,9010&lt;/P&gt;&lt;P&gt;2012,5725,9443&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 23 Feb 2013 18:55:59 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2013-02-23T18:55:59Z</dc:date>
    <item>
      <title>Displaying percentage change over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116728#M32184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to output the growth percentage from one year to the next.&amp;nbsp; For ease of showing, I've condensed the data to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines dlm=',' dsd;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input year $ gr_count ug_count @@;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;"2008",5045,7420&lt;/P&gt;&lt;P&gt;"2009",5500,7837&lt;/P&gt;&lt;P&gt;"2010",5696,8481&lt;/P&gt;&lt;P&gt;"2011",5708,9010&lt;/P&gt;&lt;P&gt;"2012",5725,9443&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;What I would like the report to look like (as close as possible) is this:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;----&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9.02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.56&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.21&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.30&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.27&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;2008&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2009&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2011&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; avg&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;(gr_count percent change from previous year and overall average of all years)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;( change = ( (2009-gr_count-# - 2008-gr_count-#) / (2008-gr_count-#) )&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;* 100 )&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;( 9.02 = ( (5500-5045)/5045 ) * 100 ) rounded to two decimal places )&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;( avg = percentages summed and divided by number of percentages )&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;The actual data has year and class, and has 12,465 total records for year 2008 (with 5,045 where class = 'gr' and 7,420 where class = 'ug', 13,337 total records for 2009, etc., and there are other fields that for which I will need to calculate the growth (in different outputs).&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;I'd love to program SAS to do this calculation for me, but I've been working with SAS for about 2 months now, and I've been teaching myself as I go - so I have never encountered anything like this and I can't find a resource that will tell me how to do exactly this.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;STRONG&gt;Thank you.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 02:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116728#M32184</guid>
      <dc:creator>GregG</dc:creator>
      <dc:date>2013-02-21T02:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying percentage change over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116729#M32185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please find below the code you require :-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;================================================================&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;infile datalines dlm=',' dsd;&lt;/P&gt;&lt;P&gt;input year $ gr_count ug_count;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;"2008",5045,7420&lt;/P&gt;&lt;P&gt;"2009",5500,7837&lt;/P&gt;&lt;P&gt;"2010",5696,8481&lt;/P&gt;&lt;P&gt;"2011",5708,9010&lt;/P&gt;&lt;P&gt;"2012",5725,9443&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data percent;&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;a=lag(gr_count);&lt;/P&gt;&lt;P&gt;change=((gr_count-a)/a)*100;&lt;/P&gt;&lt;P&gt;mean=mean(change);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=percent out=new prefix=Year;&lt;/P&gt;&lt;P&gt;id year;&lt;/P&gt;&lt;P&gt;var change;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data final(drop= _NAME_);&lt;/P&gt;&lt;P&gt;set new;&lt;/P&gt;&lt;P&gt;Average=mean(of Year2008-Year2012);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;=======================================================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Output:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=============================================================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; Year2008&amp;nbsp;&amp;nbsp;&amp;nbsp; Year2009&amp;nbsp;&amp;nbsp;&amp;nbsp; Year2010&amp;nbsp;&amp;nbsp;&amp;nbsp; Year2011&amp;nbsp;&amp;nbsp;&amp;nbsp; Year2012&amp;nbsp;&amp;nbsp;&amp;nbsp; Average&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9.01883&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.56364&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.21067&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.29783&amp;nbsp;&amp;nbsp;&amp;nbsp; 3.27274&lt;/P&gt;&lt;P&gt;==============================================================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Daman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Feb 2013 03:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116729#M32185</guid>
      <dc:creator>damanaulakh88</dc:creator>
      <dc:date>2013-02-21T03:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying percentage change over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116730#M32186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; As an alternative, that does not need the final PROC TRANSPOSE or the last DATA step, you could use either PROC REPORT or PROC TABULATE directly on the PERCENT dataset. The hardest part is doing the LAG and once you have that, there's no need to transpose in a second pass through the data or take the average in a third pass through the data. See attached screenshot produced with the code below. Notice that in my data, I do not get the MEAN variable in the PERCENT dataset, because both REPORT and TABULATE can calculate the MEAN statistic. PROC REPORT does need a "row" variable when you use ACROSS, which I called ROWVAR. If you don't want to see it, you could always put NOPRINT as an option on the DEFINE statement. But, TABULATE does not need a row item. It can make a table entirely with COLUMNS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Also, in my PERCENT data, I make an "ALT_CHANGE" variable that is not multiplied by 100. If you want to use the SAS PERCENT format for display of a "%", it will do an automatic multiply by 100.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;data new;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;infile datalines dlm=',' dsd;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;input year $ gr_count ug_count;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;datalines;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;"2008",5045,7420&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;"2009",5500,7837&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;"2010",5696,8481&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;"2011",5708,9010&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;"2012",5725,9443&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;data percent;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;set new;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;a=lag(gr_count);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;change=((gr_count-a)/a)*100;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;alt_change=((gr_count-a)/a);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;rowvar = 'Percent Change';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;put _all_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;options missing = '-';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods listing close;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html file='use proc report.html';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc report data=percent nowd;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;title '1) Using PROC REPORT instead of TRANSPOSE';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; column rowvar change,year change=cmean;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define rowvar / group 'Type';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define year / across;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define change / mean ' ' f=9.2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define cmean / mean 'Overall Average' f=9.2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc report data=percent nowd;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;title '2) Getting % with PROC REPORT and NO TRANSPOSE';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; column rowvar alt_change,year alt_change=cmean;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define rowvar / group 'Type';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define year / across;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define alt_change / mean ' ' f=percent9.2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define cmean / mean 'Overall Average' f=percent9.2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc tabulate data=percent f=9.2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title '3 Using PROC TABULATE and NO TRANSPOSE';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; class year;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; var change;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; table year*change=' '*mean=' ' all*change=' '*mean=' ';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html close;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&lt;SPAN style="color: #575757;"&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;options missing='.';&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Feb 2013 17:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116730#M32186</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-02-23T17:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying percentage change over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116731#M32187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you both so much!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ended up using a little from both - the key was the lag function!&amp;nbsp; Once I was aware of that, it was MUCH easier.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my original "code sample", I included the ( * 100 ) bit, but I took that out and opted for the PERCENT8.2 format instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Feb 2013 17:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116731#M32187</guid>
      <dc:creator>GregG</dc:creator>
      <dc:date>2013-02-23T17:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying percentage change over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116732#M32188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You already have two useful suggestions but, since you are learning SAS, I decided to throw in one more that does everything in one simple datastep.&amp;nbsp; Is there any reason why you enter year as a character variable?&amp;nbsp; In the following, I enter the years as numbers:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new (keep=year2008-year2012 Avg);&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines dlm=',' dsd eof=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array gr_array(2008:2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array ug_array(2008:2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp; array year_array(2008:2012) year2008-year2012;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format year2008-year2012 Avg percent8.2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; retain gr_array ug_array;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input year gr_count ug_count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; gr_array(year)=gr_count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ug_array(year)=ug_count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; year_array(year)=year;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return;&lt;/P&gt;&lt;P&gt;&amp;nbsp; last:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do year=2009 to 2012;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year_array(year)=gr_array(year)/gr_array(year-1)-1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Avg=mean(of Year2008-Year2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;2008,5045,7420&lt;/P&gt;&lt;P&gt;2009,5500,7837&lt;/P&gt;&lt;P&gt;2010,5696,8481&lt;/P&gt;&lt;P&gt;2011,5708,9010&lt;/P&gt;&lt;P&gt;2012,5725,9443&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Feb 2013 18:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116732#M32188</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-02-23T18:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying percentage change over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116733#M32189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, if you like the approach I suggested, you could wrap it in a macro and build all of your output files in one step.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines dlm=',' dsd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input year gr_count ug_count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;2008,5045,7420&lt;/P&gt;&lt;P&gt;2009,5500,7837&lt;/P&gt;&lt;P&gt;2010,5696,8481&lt;/P&gt;&lt;P&gt;2011,5708,9010&lt;/P&gt;&lt;P&gt;2012,5725,9443&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%macro dothemall;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; into:names separated by " "&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from dictionary.columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where libname="WORK" and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memname="HAVE" and&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lowcase(name) ne "year"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let i=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do %while (%scan(&amp;amp;names,&amp;amp;i.," ") ne );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data %scan(&amp;amp;names,&amp;amp;i.," ") (keep=year2008-year2012 Avg);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have (keep=year %scan(&amp;amp;names,&amp;amp;i.," ")) end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array var_array(2008:2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; array year_array(2008:2012) year2008-year2012;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format year2008-year2012 Avg percent8.2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; retain var_array;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_array(year)=%scan(&amp;amp;names,&amp;amp;i.," ");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year_array(year)=year;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if last then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do year=2009 to 2012;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; year_array(year)=var_array(year)/var_array(year-1)-1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Avg=mean(of Year2008-Year2012);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let i=%eval(&amp;amp;i.+1);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend dothemall;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%dothemall&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Feb 2013 20:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116733#M32189</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-02-23T20:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: Displaying percentage change over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116734#M32190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Arthur,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your additional methods.&amp;nbsp; It may take me a while to fully unpack and adapt your method, but I definitely love learning different approaches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using year as a string because I am using it as the vbar in a gchart. When I tried this with numerical year, it would create classes (2002.5 2007.5, etc), and I need things reported by instances per year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There may be another way, but I was handed this as a kind of last minute thing, so much of what I did was "brute force" and not particularly elegant, even by the standards of what little knowledge I have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have completed the report, which used nearly 400,000 records split across 11 years and was reported differently on 27 pages, each with a gchart and a table that reported percentage growth of different variables per year.&amp;nbsp; Now that it is done, I plan on exploring various method and seeing if I can tighten it up a bit.&amp;nbsp; I've used macros in the past before, but due to the rushed nature of this, and how I (at least initially) felt that each page was different enough to make the macro not my best option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The lag function, of which I was not previously aware, made a huge difference - but I also like elegant solutions when I understand them. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 14:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Displaying-percentage-change-over-time/m-p/116734#M32190</guid>
      <dc:creator>GregG</dc:creator>
      <dc:date>2013-02-26T14:52:54Z</dc:date>
    </item>
  </channel>
</rss>

