<?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 Formating date before merge in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193157#M48471</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;My task is to merge two tables based on a common variable (permno) conditioned on the effective dates for this variable. The date variable must be manipulated before the merge can be done. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;Attached datasets provide examples of my data. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;My goal is to add gvkey to my &lt;/SPAN&gt;PermnoData. To do this, I will merge by &lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;permno two times. First time, I will rename &lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;supplierpermno to permno, (supplierpermno is the permno of a firm that acts as a supplier, think of a company that supplies the glass to Apple for IPHONE product). I need your help &lt;STRONG&gt;with date manipulation&lt;/STRONG&gt;. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black;"&gt;The date variables are in different formats in two datasets: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PermnoData &lt;SPAN style="color: black;"&gt;fiscalyearenddate &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;length8, format best 12. informat best32.&lt;/SPAN&gt; , &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;FirmData firsteffectivedate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lasteffectivedate length8,&amp;nbsp; YYMMDDN8.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;11346 79363 record has the date 19950331: this means that this supplier customer pair relation is effective for fiscal year ending march 31 1995, (fiscal year starts 364 days earlier than 3/31/195, which is 4/1/1994, ). The concept of fiscal year : some firms do not have their fiscal year start on Jan. 1 and end on Dec. 31. For these firms , we compute its fiscal year the following way, if the fiscal year end month is May or earlier, then fiscal year is calendar minus 1. So my 11346 -79363 pair has a fiscal year of 1994 and 1995 for the two records. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;My goal is to add gvkey 28272 (from firmdata to PermnoData) as long as the fiscalyear matches within the range of firsteffectivedate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and lasteffectivedate. In firmdata, 79363 is effective between 19930607 and 20120331. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;I need your help with coding:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL style="list-style-type: decimal;"&gt;&lt;LI&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;Do I need generate a fiscalyearbegdate for each row in Permnodata? How do I do that? &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;After merge is done , how do I create a fiscal year measure based on fiscalyearenddate?&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Lan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 May 2015 16:36:50 GMT</pubDate>
    <dc:creator>LanMin</dc:creator>
    <dc:date>2015-05-26T16:36:50Z</dc:date>
    <item>
      <title>Formating date before merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193157#M48471</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;My task is to merge two tables based on a common variable (permno) conditioned on the effective dates for this variable. The date variable must be manipulated before the merge can be done. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;Attached datasets provide examples of my data. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;My goal is to add gvkey to my &lt;/SPAN&gt;PermnoData. To do this, I will merge by &lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt;permno two times. First time, I will rename &lt;/SPAN&gt;&lt;SPAN style="color: black;"&gt;supplierpermno to permno, (supplierpermno is the permno of a firm that acts as a supplier, think of a company that supplies the glass to Apple for IPHONE product). I need your help &lt;STRONG&gt;with date manipulation&lt;/STRONG&gt;. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: black;"&gt;The date variables are in different formats in two datasets: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PermnoData &lt;SPAN style="color: black;"&gt;fiscalyearenddate &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;length8, format best 12. informat best32.&lt;/SPAN&gt; , &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;FirmData firsteffectivedate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lasteffectivedate length8,&amp;nbsp; YYMMDDN8.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;11346 79363 record has the date 19950331: this means that this supplier customer pair relation is effective for fiscal year ending march 31 1995, (fiscal year starts 364 days earlier than 3/31/195, which is 4/1/1994, ). The concept of fiscal year : some firms do not have their fiscal year start on Jan. 1 and end on Dec. 31. For these firms , we compute its fiscal year the following way, if the fiscal year end month is May or earlier, then fiscal year is calendar minus 1. So my 11346 -79363 pair has a fiscal year of 1994 and 1995 for the two records. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;My goal is to add gvkey 28272 (from firmdata to PermnoData) as long as the fiscalyear matches within the range of firsteffectivedate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and lasteffectivedate. In firmdata, 79363 is effective between 19930607 and 20120331. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;I need your help with coding:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL style="list-style-type: decimal;"&gt;&lt;LI&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;Do I need generate a fiscalyearbegdate for each row in Permnodata? How do I do that? &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;After merge is done , how do I create a fiscal year measure based on fiscalyearenddate?&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: 'Arial',sans-serif; color: #222222; background: white;"&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Lan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 16:36:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193157#M48471</guid>
      <dc:creator>LanMin</dc:creator>
      <dc:date>2015-05-26T16:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Formating date before merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193158#M48472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;First thing will be getting firsteffectivedate and lasteffectivedate as date values so they can be manipulated easier. Best would have been reading them from the source as dates but&lt;/P&gt;&lt;P&gt;firsteffectivedate = input(put(firsteffectivedate, best8.),yymmdd8.); and similar for the other variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Somewhere you're going to have to supply WHICH suppliers use which fiscal year.&lt;/P&gt;&lt;P&gt;Comparisons can involve shifts using INTNX and INTCK functions.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 18:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193158#M48472</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-05-26T18:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Formating date before merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193159#M48473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why are the formats attached to the date variables different?&amp;nbsp; Can you fix that first?&lt;/P&gt;&lt;P&gt;If you read the string '19950331' as a number then SAS will store it as the number 19,950,331.&amp;nbsp; But if you read it using the informat YYMMDD then SAS will store it as the number 12,873.&amp;nbsp; So you should convert 19,950,331 to a SAS date value using the INPUT function.&lt;/P&gt;&lt;P&gt;INPUT(cats(fiscalyearenddate),yymmdd8.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once you get the dates using the same system then you need to clarify how you want to combine the data.&amp;nbsp; Do you want the value of GVKEY for the records where PERMNO matches the CustomerPermo or the SupplierPermno? Or both?&amp;nbsp; &lt;/P&gt;&lt;P&gt;Perhaps something like this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; Permno ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; supplierpermno customerpermno fiscalyearenddate &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; fiscalyearenddate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;YYMMDD10.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; fiscalyearenddate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;YYMMDD10.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; supplierpermno&amp;nbsp; customerpermno fiscalyearenddate;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;11346 79363 19950331&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;11346 79363 19960331&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; firm;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; gvkey $&lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;6&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; permno firsteffectivedate lasteffectivedate &lt;/SPAN&gt;&lt;STRONG style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;8&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; firsteffectivedate lasteffectivedate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; firsteffectivedate lasteffectivedate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; gvkey permno firsteffectivedate lasteffectivedate ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;13393 11346 19870519 19990331&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;28272 79363 19930607 20120331&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;;;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; want &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;a.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;*,b.gvkey &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; SupplierGVKey,c.gvkey &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; CustomerGVKey &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; permno a&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;left&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;join&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; firm b &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; a.supplierpermno = b.permno&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; a.fiscalyearenddate between b.firsteffectivedate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; b.lasteffectivedate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;left&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;join&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; firm c&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; a.customerpermno = c.permno&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; a.fiscalyearenddate between c.firsteffectivedate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; c.lasteffectivedate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" cellpadding="0" cellspacing="0" style="border: none;" summary="Procedure Print: Data Set WORK.WANT"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD style="border-top: solid black 1.0pt; border-left: none; border-bottom: solid black 1.0pt; border-right: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="79"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Supplier&lt;/STRONG&gt;&lt;/P&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;permno&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: solid black 1.0pt; border-left: none; border-bottom: solid black 1.0pt; border-right: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Customer&lt;/STRONG&gt;&lt;/P&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;permno&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: solid black 1.0pt; border-left: none; border-bottom: solid black 1.0pt; border-right: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="96"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Fiscalyear&lt;/STRONG&gt;&lt;/P&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;enddate&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: solid black 1.0pt; border-left: none; border-bottom: solid black 1.0pt; border-right: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="90"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Supplier&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;GVKey&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-top: solid black 1.0pt; border-left: none; border-bottom: solid black 1.0pt; border-right: none; padding: 0 5.4pt 0 5.4pt;" valign="top" width="108"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;Customer&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;GVKey&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: none; background: silver; padding: 0 5.4pt 0 5.4pt;" valign="top" width="79"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;11346&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; background: silver; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;79363&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; background: silver; padding: 0 5.4pt 0 5.4pt;" valign="top" width="96"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;1995-03-31&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; background: silver; padding: 0 5.4pt 0 5.4pt;" valign="top" width="90"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;13393&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; background: silver; padding: 0 5.4pt 0 5.4pt;" valign="top" width="108"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;28272&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="border: none; border-bottom: solid black 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="79"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;STRONG style="color: black; font-size: 12.0pt; font-family: 'Times New Roman','serif';"&gt;11346&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; border-bottom: solid black 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="102"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;79363&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; border-bottom: solid black 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="96"&gt;&lt;P align="right" style="margin-bottom: .0001pt; text-align: right;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;1996-03-31&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; border-bottom: solid black 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="90"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;13393&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border: none; border-bottom: solid black 1.0pt; padding: 0 5.4pt 0 5.4pt;" valign="top" width="108"&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 12.0pt; font-family: 'Times New Roman','serif'; color: black;"&gt;28272&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 May 2015 22:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193159#M48473</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-05-26T22:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Formating date before merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193160#M48474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your nice coding ! the Proc sql part is especially helpful . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me answer your first question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The attached file from my #1 post are examples of my sample data. My data was downloaded from commercial database, and the 2 date variables from firmdata is different from the date &lt;SPAN style="font-size: 13.3333330154419px;"&gt;variable from permno data. I am not proficient with sas date,so I did not know how to convert them into the same format. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see you used my txt file to input the data using the same format and informat. My data are already in sas data format, and I agree with ballardw #2 post , using &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;firsteffectivedate = input(put(firsteffectivedate, best8.),yymmdd8.) which is the same as your suggested method of using &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;INPUT(cats(fiscalyearenddate),yymmdd8.).&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 00:46:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193160#M48474</guid>
      <dc:creator>LanMin</dc:creator>
      <dc:date>2015-05-27T00:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Formating date before merge</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193161#M48475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following Tom's post above, I have merged the two data using proc sql, it contains endatefiscalyear YYMMDD10. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how do I generate the fiscal year from this variable. &lt;/P&gt;&lt;P&gt;fiscal year is defined as follows:&amp;nbsp; &lt;/P&gt;&lt;P&gt;suppose &lt;SPAN style="font-size: 13.3333330154419px;"&gt;endatefiscalyear = 19990531&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if a company's fiscal year end month is on or before may, then fiscal year is calendar year minus 1, in above example, this company fiscal year is 1998, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;if a company's fiscal year end month is on or after June, then fiscal year is the same as calendar year , in following example, &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;endatefiscalyear = 19990831&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;this company fiscal year is 1999.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;could you show me the function to generate fiscal year based on above rule and &lt;SPAN style="font-size: 13.3333330154419px;"&gt;endatefiscalyear YYMMDD10. ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Lan&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2015 02:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Formating-date-before-merge/m-p/193161#M48475</guid>
      <dc:creator>LanMin</dc:creator>
      <dc:date>2015-05-27T02:10:46Z</dc:date>
    </item>
  </channel>
</rss>

