<?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: Adding a time macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/536540#M147446</link>
    <description>&lt;OL&gt;
&lt;LI&gt;What is it that you are trying to do?&lt;/LI&gt;
&lt;LI&gt;In the first step you are using&amp;nbsp; "by gvkey"&amp;nbsp; and "if last.gvkey".&amp;nbsp;This does NOT provide the last gvkey.&amp;nbsp; It provides the last record for each GVKEY.&amp;nbsp; Since your data is probably sorted by gvkey and annual dates within gvkey, you're getting the most recent record for each gvkey.&lt;/LI&gt;
&lt;LI&gt;Your are apparently using Compustat data (company identifier is GVKEY).&amp;nbsp; Are you aware that FYEAR (as used in Compustat) is a fiscal-year, not a calendar year.&amp;nbsp; If so, then for companies that use fiscal years other than Jan-Dec your proc SQL may not produce the match you want in the expression&amp;nbsp; "(b.fyear=(year(a.DLDTE)))".&lt;/LI&gt;
&lt;LI&gt;Also you are matching not on gvkey, but on SICH&amp;nbsp; (historical SIC code - i.e. SIC code contemporary to DLDTE or FYEAR, I forget which).&amp;nbsp; Are you intentionally doing a Cartesian crossing of all gvkeys that have matching fyear's and dldte's that are active in the same industry?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In short, I repeat - what are you trying to do?&amp;nbsp; I.e. what data organization and content&amp;nbsp;are you trying to produce?&lt;/P&gt;</description>
    <pubDate>Mon, 18 Feb 2019 18:14:46 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2019-02-18T18:14:46Z</dc:date>
    <item>
      <title>Adding a time macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/536533#M147444</link>
      <description>&lt;P&gt;Hello y`all!&lt;BR /&gt;&lt;BR /&gt;I stumble upon a tricky part of my program. I need to add a macro variable, or something similar, that will let me chose the gvkey that I want. For example I could chose the last one, the one before or even the first one. But it has to be done in one command.&lt;BR /&gt;&lt;BR /&gt;For now I`ve manage to have the last one or the first one but I haven`t managed to add a SQL proc or a normal statement that let me chose whichever I want to see in my program (match2) for further analisys&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my code:&lt;/P&gt;&lt;P&gt;Data Last_Avail_Bnkrpt2;&lt;BR /&gt;set Inactive;&lt;BR /&gt;Last_Year=Fyear;&lt;BR /&gt;by gvkey;&lt;BR /&gt;if last.gvkey then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table Appareillement2 as&lt;BR /&gt;select distinct b.*&lt;BR /&gt;from Last_Avail_Bnkrpt2 as a, Active as b&lt;BR /&gt;where a.SICH=b.SICH and (b.fyear=(year(a.DLDTE)));&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Last_Avail_Alive2;&lt;BR /&gt;set Appareillement2 ;&lt;BR /&gt;Last_Year=Fyear;&lt;BR /&gt;by gvkey;&lt;BR /&gt;if last.gvkey then output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data match2;&lt;BR /&gt;set Last_Avail_Alive2 Last_Avail_Bnkrpt2;&lt;BR /&gt;format DLDTE year4.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data=match2; by fyear sich ;run&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas4.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27264i19A95EAD259042E7/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas4.png" alt="sas4.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas3.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27265iFC1E9A38CEC7C6ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas3.png" alt="sas3.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas2.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27267i85A459EF80368863/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas2.png" alt="sas2.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas1.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27266i2B595FF7349F5975/image-size/large?v=v2&amp;amp;px=999" role="button" title="sas1.png" alt="sas1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 16:57:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/536533#M147444</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-02-18T16:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a time macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/536540#M147446</link>
      <description>&lt;OL&gt;
&lt;LI&gt;What is it that you are trying to do?&lt;/LI&gt;
&lt;LI&gt;In the first step you are using&amp;nbsp; "by gvkey"&amp;nbsp; and "if last.gvkey".&amp;nbsp;This does NOT provide the last gvkey.&amp;nbsp; It provides the last record for each GVKEY.&amp;nbsp; Since your data is probably sorted by gvkey and annual dates within gvkey, you're getting the most recent record for each gvkey.&lt;/LI&gt;
&lt;LI&gt;Your are apparently using Compustat data (company identifier is GVKEY).&amp;nbsp; Are you aware that FYEAR (as used in Compustat) is a fiscal-year, not a calendar year.&amp;nbsp; If so, then for companies that use fiscal years other than Jan-Dec your proc SQL may not produce the match you want in the expression&amp;nbsp; "(b.fyear=(year(a.DLDTE)))".&lt;/LI&gt;
&lt;LI&gt;Also you are matching not on gvkey, but on SICH&amp;nbsp; (historical SIC code - i.e. SIC code contemporary to DLDTE or FYEAR, I forget which).&amp;nbsp; Are you intentionally doing a Cartesian crossing of all gvkeys that have matching fyear's and dldte's that are active in the same industry?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In short, I repeat - what are you trying to do?&amp;nbsp; I.e. what data organization and content&amp;nbsp;are you trying to produce?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Feb 2019 18:14:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/536540#M147446</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-02-18T18:14:46Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a time macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/536903#M147604</link>
      <description>&lt;P&gt;To answer your questions:&lt;BR /&gt;&lt;BR /&gt;1.&lt;SPAN&gt;What I am trying to do is add a variable that will let me decide which gvkey I want to see when the program runs&lt;BR /&gt;Right now my code tells SAS &lt;/SPAN&gt;&amp;nbsp;to provide the last record for each GVKEY. I would like to add a variable that let me change which GVKEY I’d see (the last one, the one before that, the 5thor the 3rd,etc..). Since the GVKEY will eventually take me to the year value I want to see (as you said the latest GVKEY is the most recent record, but I would like to be able to chose which record to see in order to properly analyse the data 1 or 2 or even 5 years prior the DLDTE date )&lt;BR /&gt;&lt;BR /&gt;The end goal of the program is to be able to see a bankrupt company (witch DLDRSN= 02 or 03) that is inactive (COSTAT=1) on one line and a non-bankrupt company the line before from the same industry (SICH) and the same dates (FYEAR/DLDTE Year) or as close as possible this way :&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DATADATE FYEAR DLRSN CONM DLDTE COSTAT&amp;nbsp; SICH&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;03/12/1992 1989&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;.&amp;nbsp; &amp;nbsp;&amp;nbsp; A&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; 0&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 112&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;03/12/1993 1989&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02&amp;nbsp; &amp;nbsp; B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1990&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;112&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;03/12/1994 1990&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; D &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;0 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;333&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;03/12/1992 1990&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03&amp;nbsp;&amp;nbsp;&amp;nbsp; F&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1992 &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; 333&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;03/12/1993 1994&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; J&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;0 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;445&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;03/12/1994 1994&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03&amp;nbsp;&amp;nbsp;&amp;nbsp; L&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1996&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;445&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;03/12/1998 1998&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; I&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;0&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;001&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;03/12/1998 1998&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02&amp;nbsp;&amp;nbsp;&amp;nbsp; Z&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2000 &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; 001&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;…..&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;2. Yes I did it on purpose, sorry if it wasn't clear on my first post.&lt;BR /&gt;3. Yes I do know that Fyear is the fiscal year and since I am dealing with company bankruptcy I need to take it into account , since actual years are not represented in financial ratios&lt;/P&gt;&lt;P&gt;4. I have to match by SICH or SIC or NAICS because I need the companies that I will compare in the future to be in the same industry&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 20:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/536903#M147604</guid>
      <dc:creator>Pabster</dc:creator>
      <dc:date>2019-02-19T20:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a time macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/537339#M147777</link>
      <description>The Issue Description is not to the point.&lt;BR /&gt;Can you describe what you have and what do you want as in table format.&lt;BR /&gt;And provide any sample code if you have tried.</description>
      <pubDate>Thu, 21 Feb 2019 08:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-a-time-macro-variable/m-p/537339#M147777</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-02-21T08:36:41Z</dc:date>
    </item>
  </channel>
</rss>

