<?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 Firm Age in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445549#M111661</link>
    <description>&lt;P&gt;Would you please show a sample of how your starting data looks?&amp;nbsp; And how you want the result to look like?&lt;/P&gt;</description>
    <pubDate>Wed, 14 Mar 2018 17:06:24 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-03-14T17:06:24Z</dc:date>
    <item>
      <title>Calculate Firm Age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445537#M111654</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to calculate the firm age based on&amp;nbsp;FISCAL_YEAR_END_OP. I am trying to index the file in order to calculate from the first to late date of the opinion in my dataset. I am not able to output an age based on the code below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=opinion;&lt;BR /&gt;by COMPANY_FKEY FISCAL_YEAR_END_OP;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data age;&lt;BR /&gt;retain index;&lt;BR /&gt;set opinion;&lt;BR /&gt;if index=. then index=0;&lt;BR /&gt;if COMPANY_FKEY = lag(COMPANY_FKEY) then index=index;&lt;BR /&gt;else index=index+1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data age;&lt;BR /&gt;set age;&lt;BR /&gt;by index;&lt;BR /&gt;if first.index then output age;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 16:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445537#M111654</guid>
      <dc:creator>dlazer1</dc:creator>
      <dc:date>2018-03-14T16:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Firm Age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445544#M111658</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=opinion;
    by company_fkey fiscal_year_end_op;
run;
data age;
    set opinion;
    lag_company_fkey=lag(company_fkey);
    if company_fkey^=lag_company_fkey then index+1;
run ;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I'm not really understanding the point of your last data step.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 17:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445544#M111658</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-14T17:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Firm Age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445549#M111661</link>
      <description>&lt;P&gt;Would you please show a sample of how your starting data looks?&amp;nbsp; And how you want the result to look like?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 17:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445549#M111661</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-03-14T17:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Firm Age</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445553#M111664</link>
      <description>&lt;P&gt;Show some example data. Is your FISCAL_YEAR_END_OP a SAS date value, a numeric that represents a year, something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I doubt if your "index" is at all needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your FISCAL_YEAR_END_OP is a year value such as 1994 then this might be as simple as:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc means data=opinion range; (or since you are counting with your "index" use N instead of range to get number of records for each company_fkey)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class COMPANY_FKEY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;var&amp;nbsp;FISCAL_YEAR_END_OP;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but without knowing what kind of values it is pretty hard to tell whether the calculation you are using is appropriate or not.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 17:28:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-Firm-Age/m-p/445553#M111664</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-14T17:28:16Z</dc:date>
    </item>
  </channel>
</rss>

