<?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: Matched observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78929#M22761</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ksharp again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I used sum() function, so I include comma between them. If I remove the comma, the following error message appeared:&lt;/P&gt;&lt;P&gt;ERROR: Summary functions nested in this way are not supported.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used SUM instead of operator of MINUS (ie. -) as SUM will provide a value even there is missing value either on a.ROA1 or b.ROA1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Apr 2012 06:28:25 GMT</pubDate>
    <dc:creator>mspak</dc:creator>
    <dc:date>2012-04-12T06:28:25Z</dc:date>
    <item>
      <title>Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78921#M22753</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish match each firm-year (tic-fyear) observation with another from the same two-digit SIC code (sic2) and year (fyear) with the closest return on assets in the current year, ROA1. Then, I wish to obtain a performance-matched AEM (ie Jones_PDA) for all firm-years,&amp;nbsp; by subtracting the AEM of the firm with the closest ROA that is in the same industry as the firm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The closest ROA = min(abs(a.ROA1, -b.ROA1)). The lowest difference between ROA1 would be defined as closest ROA1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran a sql using the following program, however, it provides Jones_PDA for all the matched firms. I only wish to have the Jones_PDA for the matched firm with closest ROA instead. It does mean that I wish to have Jones_PDA for only ONE matched firm. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Jones_matchedROA1 as&lt;/P&gt;&lt;P&gt;select a.tic,a.fyear,a.sic2,&lt;/P&gt;&lt;P&gt;min(abs(a.ROA1, -b.ROA1)) as closest_ROA1,&lt;/P&gt;&lt;P&gt;sum(a.aem,-b.aem) as Jones_PDA&lt;/P&gt;&lt;P&gt;from geog.data a, geog.data b&lt;/P&gt;&lt;P&gt;where a.tic ne b.tic and a.fyear=b.fyear and a.sic2=b.sic2&lt;/P&gt;&lt;P&gt;group by a.tic,a.fyear,a.sic2&lt;/P&gt;&lt;P&gt;order by a.tic,a.fyear;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could anyone guide me on how to modify the program/code to achieve my desired output?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance for advices.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 07:47:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78921#M22753</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-11T07:47:03Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78922#M22754</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't open your attachment. Maybe it is corroded.&lt;/P&gt;&lt;P&gt;And What outpu do you want ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you only need to remove replicated observations. Proc sort + nodupkey is a good tool.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 08:12:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78922#M22754</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-11T08:12:00Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78923#M22755</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I changed the file name as "mydata" for this new file. I have the following variables:&lt;/P&gt;&lt;P&gt;1. tic - company identification code&lt;/P&gt;&lt;P&gt;2. fyear - financial year&lt;/P&gt;&lt;P&gt;3. ROA1 - performance measure, returns on assets&lt;/P&gt;&lt;P&gt;4. SIC2 - 2-digit SIC industry classification code&lt;/P&gt;&lt;P&gt;5. AEM - it is a residual as an output from proc reg&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish to have an output file with the following columns:&lt;/P&gt;&lt;P&gt;1. tic&lt;/P&gt;&lt;P&gt;2. fyear&lt;/P&gt;&lt;P&gt;3. Jones_PDA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jones_PDA is the difference between the firm's AEM with the another matched firm in the following criteria:&lt;/P&gt;&lt;P&gt;a) same 2-digit SIC code&lt;/P&gt;&lt;P&gt;b) same fyear&lt;/P&gt;&lt;P&gt;c) with the closest ROA1. &lt;/P&gt;&lt;P&gt;The lowest difference between ROA1 of the firm itself and the matched firm would be defined as closest ROA1. As such, I calculate the difference as = min(abs(a.ROA1, -b.ROA1))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many firms can be matched with the firm based on SIC code and fyear. However, I would wish to restrict the ONLY ONE matched firm, that is, the one with the lowest difference in terms of their ROA1. In order to avoid self-matched, so I provide a restriction a.tic ne b.tic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, I would wish to calculate the differences in AEM between the firm and the matched firm (ie. Jones_PDA).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this make my points clearer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 09:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78923#M22755</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-11T09:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78924#M22756</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;One correction:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The lowest difference between ROA1 of the firm itself and the matched firm would be defined as closest ROA1. As such, I calculate the difference as = min(abs(sum(a.ROA1, -b.ROA1))).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. the difference between ROA1&lt;/P&gt;&lt;P&gt;2. as the difference can be positive and negative, so I used ABS (absolute value).&lt;/P&gt;&lt;P&gt;3. In order to further restrict to only firm, so I should choose the lowest value. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 09:43:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78924#M22756</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-11T09:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78925#M22757</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;This is the file. I tried to upload the file from my notebook's desktop instead of my hard disk. I am not sure whether it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mspak &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 14:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78925#M22757</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-11T14:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78926#M22758</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;I tried to open this file. This data can be opened. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MEI SEN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 23:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78926#M22758</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-11T23:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78927#M22759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK. MEI SEN&lt;/P&gt;&lt;P&gt;I noticed a problem in your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;min(abs(&lt;STRONG&gt;a.ROA1-b.ROA1&lt;/STRONG&gt;)) as closest_ROA1,&lt;/P&gt;&lt;P&gt;sum(&lt;STRONG&gt;a.aem-b.aem&lt;/STRONG&gt;) as Jones_PDA&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need a comma between them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you remove comma, maybe the result is what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 06:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78927#M22759</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-12T06:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78928#M22760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ksharp,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I ran the following program, it seems leading to my desired output:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Jones_matchedROA1 as&lt;/P&gt;&lt;P&gt;select unique a.tic,a.fyear,a.sic2,a.aem, a.roa1, b.roa1,&lt;/P&gt;&lt;P&gt;abs(sum(a.ROA1, -b.ROA1))as DIFF_ROA1, min(calculated DIFF_ROA1)as CLOSEST_ROA1, &lt;/P&gt;&lt;P&gt;sum(a.aem,-b.aem)as Jones_PDA&lt;/P&gt;&lt;P&gt;from geog.mydata a, geog.mydata b&lt;/P&gt;&lt;P&gt;where a.tic ne b.tic and a.fyear=b.fyear and a.sic2=b.sic2&lt;/P&gt;&lt;P&gt;group by a.tic,a.fyear,a.sic2&lt;/P&gt;&lt;P&gt;having DIFF_ROA1=CLOSEST_ROA1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only ONE observation per firm-year will be derived by providing "having DIFF_ROA1=CLOSEST_ROA1" clause, that is the one with lowest difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone confirm this is correct?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MEI SEN&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 06:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78928#M22760</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-12T06:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78929#M22761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ksharp again,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As I used sum() function, so I include comma between them. If I remove the comma, the following error message appeared:&lt;/P&gt;&lt;P&gt;ERROR: Summary functions nested in this way are not supported.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used SUM instead of operator of MINUS (ie. -) as SUM will provide a value even there is missing value either on a.ROA1 or b.ROA1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 06:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78929#M22761</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-12T06:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78930#M22762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;En....&lt;/P&gt;&lt;P&gt;You code looks good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;having DIFF_ROA1=CLOSEST_ROA1;&lt;/P&gt;&lt;P&gt;Only pick up the observation which has the minimize value for each group.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 09:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78930#M22762</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-04-12T09:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78931#M22763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ksharp and other experts' help, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have learned a lot from the discussion in SAS forum.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;mspak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 11:48:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/78931#M22763</guid>
      <dc:creator>mspak</dc:creator>
      <dc:date>2012-04-12T11:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Matched observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/423179#M68100</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Good afternoon. I am working on the same replication paper: SP Kothari 2005. Could you tell me if the you have encountered the problem that a performance matched firm can bot be obtained? I mean I used your code with the modification of Ksharp. I did not find any missing var for the ***PDAs.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2017 18:27:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Matched-observations/m-p/423179#M68100</guid>
      <dc:creator>fafrin420</dc:creator>
      <dc:date>2017-12-21T18:27:36Z</dc:date>
    </item>
  </channel>
</rss>

