<?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: Inflation cost analysis in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840408#M332297</link>
    <description>&lt;P&gt;Using a macro seems unnecessary and inefficient here. I have also written the code assuming year is a numeric variable, which it should be. You will have to somehow create a list of variables in the ARRAY statement, if their names all begin with COST_ then it's pretty simple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
     set b2007_2011;
     if obsyear=2006 then factor=1.1;
     else if obsyear=2007 then factor=1.08;
     else if /* you type the rest */ ;
     array cost cost_:;
     do i=1 to dim(cost);
         cost(i)=factor*cost(i);
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2022 22:12:58 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-10-24T22:12:58Z</dc:date>
    <item>
      <title>Inflation cost analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840387#M332294</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am doing inflation cost analysis which am new to using sas. I will like to produce an output for all cost variables but I only have output for total.&lt;/P&gt;&lt;P&gt;Please any help with how the code can generate the outputs e.g. inf_cost_hosp,&amp;nbsp;inf_cost_ed,&lt;/P&gt;&lt;P&gt;inf_cost_rx and&amp;nbsp;inf_cost_out and not only the inf_cost_total?&lt;/P&gt;&lt;P&gt;Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro cost(var1);&lt;BR /&gt;data a2007_2011;&lt;BR /&gt;set b2007_2011;&lt;BR /&gt;if obsyear='2006' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.10;&lt;BR /&gt;else if obsyear='2007' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.08;&lt;BR /&gt;else if obsyear='2008' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.04;&lt;BR /&gt;else if obsyear='2009' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.04;&lt;BR /&gt;else if obsyear='2010' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.01;&lt;BR /&gt;else inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.;&lt;BR /&gt;run;&lt;BR /&gt;%mend cost;&lt;BR /&gt;%cost(hosp);&lt;BR /&gt;%cost(ed);&lt;BR /&gt;%cost(out);&lt;BR /&gt;%cost(rx);&lt;BR /&gt;%cost(total);&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 21:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840387#M332294</guid>
      <dc:creator>CathyVI</dc:creator>
      <dc:date>2022-10-24T21:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Inflation cost analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840408#M332297</link>
      <description>&lt;P&gt;Using a macro seems unnecessary and inefficient here. I have also written the code assuming year is a numeric variable, which it should be. You will have to somehow create a list of variables in the ARRAY statement, if their names all begin with COST_ then it's pretty simple.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
     set b2007_2011;
     if obsyear=2006 then factor=1.1;
     else if obsyear=2007 then factor=1.08;
     else if /* you type the rest */ ;
     array cost cost_:;
     do i=1 to dim(cost);
         cost(i)=factor*cost(i);
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 22:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840408#M332297</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-10-24T22:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Inflation cost analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840412#M332298</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
     set b2007_2011;
     array _factor[2006:2010] _temporary_ (1.10, 1.08, 1.04, 1.04, 1.01)
     _year = input(year, 8.);
     array cost cost_:;
     do i=1 to dim(cost);&lt;BR /&gt;        if  2006&amp;lt;=year&amp;lt;=2010 then factor=_factor(year);&lt;BR /&gt;        else factor=1;
         cost(i)=factor*cost(i);
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Adding the factors into an array makes it easier as well.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 22:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840412#M332298</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-24T22:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Inflation cost analysis</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840413#M332299</link>
      <description>&lt;P&gt;And how to make your code actually work as is. You were always starting from the base data set, overwriting any previous changes. To have the changes stick, you need to use the same data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro cost(var1);
data b2007_2011;
set b2007_2011;
if obsyear='2006' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.10;
else if obsyear='2007' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.08;
else if obsyear='2008' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.04;
else if obsyear='2009' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.04;
else if obsyear='2010' then inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.*1.01;
else inf_cost_&amp;amp;var1.=cost_&amp;amp;var1.;
run;
%mend cost;

data b2007_2011;
set a2007_2011;
run;


%cost(hosp);
%cost(ed);
%cost(out);
%cost(rx);
%cost(total);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Oct 2022 22:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Inflation-cost-analysis/m-p/840413#M332299</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-10-24T22:49:51Z</dc:date>
    </item>
  </channel>
</rss>

