<?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: 3-year period for each firm in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519022#M140514</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I have created:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date1=beg_fyr;&lt;/P&gt;&lt;P&gt;format date1 date9.;&lt;/P&gt;&lt;P&gt;date2= intnx('month', beg_fyr,36,'beg');&lt;/P&gt;&lt;P&gt;format date2 date9.;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Dec 2018 06:02:25 GMT</pubDate>
    <dc:creator>MarinaMag</dc:creator>
    <dc:date>2018-12-06T06:02:25Z</dc:date>
    <item>
      <title>3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519017#M140511</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have monthly data for multiple firms.&lt;/P&gt;&lt;P&gt;I have taken the begging of the fiscal year of each firm and add 36 months to create a time interval.&lt;/P&gt;&lt;P&gt;I want the data of each firm to be assigned in a specific 3-year period.&lt;/P&gt;&lt;P&gt;eg The data of a specific firm of 1989 1990 1991 must belong in date1=1989 and date2=1991.&lt;/P&gt;&lt;P&gt;The data of&amp;nbsp;the same&amp;nbsp;specific firm of 1992 must belong in date1=1992 and date2=1994 (and not in date1=1990 and and date2=1992).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that I cannot just create periods for the entire sample, because the 3-year period is different for each firm, it is based on its fiscal year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone can help me?&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 05:33:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519017#M140511</guid>
      <dc:creator>MarinaMag</dc:creator>
      <dc:date>2018-12-06T05:33:57Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519018#M140512</link>
      <description>&lt;P&gt;Please show us some of your data in data step code.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 05:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519018#M140512</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-06T05:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519021#M140513</link>
      <description />
      <pubDate>Thu, 06 Dec 2018 06:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519021#M140513</guid>
      <dc:creator>MarinaMag</dc:creator>
      <dc:date>2018-12-06T06:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519022#M140514</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I have created:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date1=beg_fyr;&lt;/P&gt;&lt;P&gt;format date1 date9.;&lt;/P&gt;&lt;P&gt;date2= intnx('month', beg_fyr,36,'beg');&lt;/P&gt;&lt;P&gt;format date2 date9.;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 06:02:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519022#M140514</guid>
      <dc:creator>MarinaMag</dc:creator>
      <dc:date>2018-12-06T06:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519031#M140518</link>
      <description>&lt;P&gt;This is what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt; meant:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile datalines dlm=';' dsd truncover;
input
  PERMNO
  DATE :date9.
  COMNAM :$30.
  ret_crsp :commax.
  VWRETD :commax.
  VWRETX :commax.
  end_fyr :date9.
  beg_fyr :date9.
  year
  month :commax.
  mktrf :commax.
  rf :commax.
  risk_free :commax.
  market_premium :commax.
  ex_ret_mon :commax.
  date1 :date9.
  date2 :date9.
;
format date end_fyr beg_fyr date1 date2 date9.;
datalines4;
10000;31JAN1986;OPTIMUM MANUFACTURING INC;C;0,009829;0,008006;31OCT1986;01NOV1985;1986;1;0,65;0,56;0,0056;0,0065;;01NOV1985;01NOV1988
;;;;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Excel files are useless for presenting SAS datasets, as they do not have fixed column attributes. Data steps with datalines enable you to exactly tell us how your dataset is structured and what content it has; we can recreate it by simply copying the code and submitting it.&lt;/P&gt;
&lt;P&gt;No importing needed, which will in most cases give us a dataset different from the one you are using.&lt;/P&gt;
&lt;P&gt;A macro that does the conversion of a dataset to a data step automatically is found in my second footnote.&lt;/P&gt;
&lt;P&gt;Creating example/simulation data with a data step is an essential SAS skill which will always be useful in your SAS future.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 07:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519031#M140518</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-06T07:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519033#M140519</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/186352"&gt;@MarinaMag&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here I have created:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;date1=beg_fyr;&lt;/P&gt;
&lt;P&gt;format date1 date9.;&lt;/P&gt;
&lt;P&gt;date2= intnx('month', beg_fyr,36,'beg');&lt;/P&gt;
&lt;P&gt;format date2 date9.;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please provide the data as data-step using datalines statement. The dataset created when importing an excel-file may differ between platforms and SAS version. And, of course, because excel is a bad file-format for storing data.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 07:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519033#M140519</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-12-06T07:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519035#M140520</link>
      <description>&lt;P&gt;Just to show you what has already happened by using Excel:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Dates are stored as character in the Excel file; this also causes them to be character after import with EG&lt;/LI&gt;
&lt;LI&gt;ret_crsp is mixed character/numeric in the Excel, so it ends up as character in the dataset; you probably had speciall "missing" values in the dataset&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The macro would have prevented all that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bottom line: when working with SAS, forget that Excel even exists on your harddisk.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 07:39:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519035#M140520</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-06T07:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519036#M140521</link>
      <description>&lt;P&gt;This program is untested, but it could be easily tested if you take &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;'s code and applied it&amp;nbsp; to all your sample data:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by permno;
  retain date1 date2;
  format date1 date2 date9. ;

  if first.permno then do;
     date1=begfyr;
     date2=intnx('year',date1,3,'same');
  end;
  if date&amp;gt;=date2 then do;
     date1=date2;
     date2=intnx('year',date1,3,'same');
  end;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I notice your date2 is actually the first date of the next three-year period.&amp;nbsp; If you prefer to make it the&amp;nbsp; last date of the current 3-year period, then instead of;&lt;/P&gt;
&lt;PRE&gt;     date2=intnx('year',date1,3,'same');
&lt;/PRE&gt;
&lt;P&gt;use&lt;/P&gt;
&lt;PRE&gt;     date2=intnx('year',date1,3,'same')-1;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;editted addition:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And also you would have to change&lt;/P&gt;
&lt;PRE&gt;  if date&amp;gt;=date2 then do;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;PRE&gt;  if date&amp;gt;date2 then do;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Dec 2018 07:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519036#M140521</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-12-06T07:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: 3-year period for each firm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519041#M140522</link>
      <description>&lt;P&gt;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Dec 2018 07:50:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/3-year-period-for-each-firm/m-p/519041#M140522</guid>
      <dc:creator>MarinaMag</dc:creator>
      <dc:date>2018-12-06T07:50:20Z</dc:date>
    </item>
  </channel>
</rss>

