<?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: matching event sample to control sample but using any control in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19612#M3997</link>
    <description>Hi Ksharp,&lt;BR /&gt;
&lt;BR /&gt;
Many thanks for your help, the code is perfect and I can find the matched protfolio easly now.&lt;BR /&gt;
&lt;BR /&gt;
your help and time are highly appreciated.</description>
    <pubDate>Wed, 02 Mar 2011 13:41:15 GMT</pubDate>
    <dc:creator>q1234</dc:creator>
    <dc:date>2011-03-02T13:41:15Z</dc:date>
    <item>
      <title>matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19608#M3993</link>
      <description>Hi All,&lt;BR /&gt;
&lt;BR /&gt;
I want to create a matched sample and while I was searching on the web, I came across a similar post by Paul&lt;BR /&gt;
. So I copy Paul's post which exactly explains what I want to do, so please if  you can help with that I will be so grateful for you.&lt;BR /&gt;
&lt;BR /&gt;
“--------hello,&lt;BR /&gt;
Since two weeks I am trying unsuccessfuly to solve the following&lt;BR /&gt;
problem. I have a sample of event firms (small sample) and non-event&lt;BR /&gt;
firms (big sample). I need to match each event firm with non-event firm&lt;BR /&gt;
that is similar on -/+30% size and closest another ratio (BEME).&lt;BR /&gt;
However, I want each control firm to be used only once (unless it is&lt;BR /&gt;
used another time five years after its first use).&lt;BR /&gt;
I found the following code, which I tried to implement in iterative way&lt;BR /&gt;
but it is not working.&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table SEO_matches as&lt;BR /&gt;
select eventfirm.*,&lt;BR /&gt;
match.id as match_id,&lt;BR /&gt;
match.ME as match_ME,&lt;BR /&gt;
match.beme as match_beme,&lt;BR /&gt;
abs(eventfirm.bemv - match.beme) as bmabsdiff&lt;BR /&gt;
from eventfirm&lt;BR /&gt;
join noneventfirms as match&lt;BR /&gt;
on (eventfirm.OfferYear1 - 1 ) = match.year&lt;BR /&gt;
where 0.7 * eventfirm.me &amp;lt; match.me &amp;lt; 1.3 * eventfirm.me&lt;BR /&gt;
and eventfirm.id^= match.idand not missing(match.beme) and not&lt;BR /&gt;
missing(match.me) group by eventfirm.id&lt;BR /&gt;
having bmabsdiff = min(bmabsdiff) ;&lt;BR /&gt;
&lt;BR /&gt;
data SEO_matches; set SEO_matches;&lt;BR /&gt;
by id;&lt;BR /&gt;
if first.id;&lt;BR /&gt;
run;&lt;BR /&gt;
-------The end of Paul post”&lt;BR /&gt;
To see Paul post open this link &lt;BR /&gt;
&lt;A href="http://www.rhinocerus.net/forum/soft-sys-sas/502636-re-matching-event-sample-control-sample-but-using-any-control.html" target="_blank"&gt;http://www.rhinocerus.net/forum/soft-sys-sas/502636-re-matching-event-sample-control-sample-but-using-any-control.html&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
Many thanks</description>
      <pubDate>Tue, 01 Mar 2011 19:34:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19608#M3993</guid>
      <dc:creator>q1234</dc:creator>
      <dc:date>2011-03-01T19:34:18Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19609#M3994</link>
      <description>What does your data look like?&lt;BR /&gt;
And what do you want output to look like??&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 02 Mar 2011 06:25:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19609#M3994</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-02T06:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19610#M3995</link>
      <description>Hi Ksharp,&lt;BR /&gt;
Many thanks for your replay. Actually, I have two groups of companies; one is the event companies about 500 and the second is the control companies around 2000. I need to match each company from the event to one company from the control, where both of them should have the same year and industry, and the size for the event companies should between 130% and 70% of the match companies’ size. After creating this matched portfolio, then each company from the event should match the closet BEME ratio from the matched portfolio. &lt;BR /&gt;
For example&lt;BR /&gt;
The event firms&lt;BR /&gt;
Firm     Year       industry    size (mill)          BEME(ratio)&lt;BR /&gt;
x          2000        20            100                   1.1&lt;BR /&gt;
y          1999         25             250                  .9&lt;BR /&gt;
&lt;BR /&gt;
The Match&lt;BR /&gt;
Firm     Year       industry    size (mill)          BEME(ratio)&lt;BR /&gt;
A          2000        20            100                   1.1&lt;BR /&gt;
J         1999         25             250                  .9&lt;BR /&gt;
K         2000        20            100                   1.1&lt;BR /&gt;
L         1999         25             250                  .9&lt;BR /&gt;
T         2000        20            100                   1.1&lt;BR /&gt;
R        1999         25             250                  .9&lt;BR /&gt;
................................................</description>
      <pubDate>Wed, 02 Mar 2011 09:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19610#M3995</guid>
      <dc:creator>q1234</dc:creator>
      <dc:date>2011-03-02T09:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19611#M3996</link>
      <description>Ok.&lt;BR /&gt;
If it is what you want:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data event;&lt;BR /&gt;
input firm $ year industry size ratio;&lt;BR /&gt;
datalines;&lt;BR /&gt;
x 2000 20 100 1.1&lt;BR /&gt;
y 1999 25 250 .9&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data match;&lt;BR /&gt;
input _firm $ _year _industry _size _ratio;&lt;BR /&gt;
datalines;&lt;BR /&gt;
A 2000 20 100 1.2&lt;BR /&gt;
J 1999 25 250 .4&lt;BR /&gt;
K 2000 20 100 1.4&lt;BR /&gt;
L 1999 25 250 .9&lt;BR /&gt;
T 2000 20 100 1.8&lt;BR /&gt;
R 1999 25 250 .2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
 create table portfolio1 as&lt;BR /&gt;
  select *&lt;BR /&gt;
   from event,match&lt;BR /&gt;
    where year=_year and industry=_industry and&lt;BR /&gt;
          (size between .7*_size and 1.3*_size)&lt;BR /&gt;
        ;&lt;BR /&gt;
&lt;BR /&gt;
 create table portfolio2 as&lt;BR /&gt;
  select *,min(abs(ratio - _ratio)) as closest&lt;BR /&gt;
   from portfolio1&lt;BR /&gt;
     group by firm&lt;BR /&gt;
        having abs(ratio - _ratio) eq calculated closest  &lt;BR /&gt;
         order by firm&lt;BR /&gt;
    ;&lt;BR /&gt;
     &lt;BR /&gt;
&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Wed, 02 Mar 2011 10:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19611#M3996</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-02T10:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19612#M3997</link>
      <description>Hi Ksharp,&lt;BR /&gt;
&lt;BR /&gt;
Many thanks for your help, the code is perfect and I can find the matched protfolio easly now.&lt;BR /&gt;
&lt;BR /&gt;
your help and time are highly appreciated.</description>
      <pubDate>Wed, 02 Mar 2011 13:41:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19612#M3997</guid>
      <dc:creator>q1234</dc:creator>
      <dc:date>2011-03-02T13:41:15Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19613#M3998</link>
      <description>Hi Ksharp,&lt;BR /&gt;
Can you help with this? I used to use this code to remove less than 10 observations for each year and industry and it works. But I need to create dataset for each year and the run it.&lt;BR /&gt;
For example if I want to run the code from 2000 to 2005 then I should have dataset for each year then I run the code for each dataset.&lt;BR /&gt;
&lt;BR /&gt;
the dataset&lt;BR /&gt;
Firm              industry       year &lt;BR /&gt;
x                       22           2001&lt;BR /&gt;
z                       33           2002&lt;BR /&gt;
v                        33           2002 &lt;BR /&gt;
b                       14            2005&lt;BR /&gt;
w                       22           2001 &lt;BR /&gt;
x                       22           2002&lt;BR /&gt;
x                       22           2003 &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
The code&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=data;&lt;BR /&gt;
by industry;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=dataset out= dataset_1;&lt;BR /&gt;
class industry;&lt;BR /&gt;
table industry*n;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data dataset_1;&lt;BR /&gt;
set dataset_1;&lt;BR /&gt;
drop _table_;&lt;BR /&gt;
drop _page_;&lt;BR /&gt;
drop _type_;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sort data= dataset;&lt;BR /&gt;
by industry;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data= dataset_1;&lt;BR /&gt;
by industry;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data dataset_2;&lt;BR /&gt;
merge dataset dataset_1;&lt;BR /&gt;
by industry;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data dataset_3;&lt;BR /&gt;
set dataset_2;&lt;BR /&gt;
if n &amp;lt; 10 then delete;&lt;BR /&gt;
run;&lt;BR /&gt;
--------------------------------------------------------------&lt;BR /&gt;
So, can you help me to modify this code to run it for pooled sample including all the years?&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 03 Mar 2011 11:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19613#M3998</guid>
      <dc:creator>q1234</dc:creator>
      <dc:date>2011-03-03T11:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19614#M3999</link>
      <description>OK.&lt;BR /&gt;
That would not be too complicated!&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data dataset;&lt;BR /&gt;
input Firm $ industry year;&lt;BR /&gt;
datalines;&lt;BR /&gt;
x 22 2001&lt;BR /&gt;
z 33 2002&lt;BR /&gt;
v 33 2002&lt;BR /&gt;
b 14 2005&lt;BR /&gt;
w 22 2001&lt;BR /&gt;
x 22 2002&lt;BR /&gt;
x 22 2003&lt;BR /&gt;
x 22 2001&lt;BR /&gt;
z 33 2002&lt;BR /&gt;
v 33 2002&lt;BR /&gt;
b 14 2005&lt;BR /&gt;
w 22 2001&lt;BR /&gt;
x 22 2002&lt;BR /&gt;
x 22 2003&lt;BR /&gt;
x 22 2001&lt;BR /&gt;
z 33 2002&lt;BR /&gt;
v 33 2002&lt;BR /&gt;
b 14 2005&lt;BR /&gt;
w 22 2001&lt;BR /&gt;
x 22 2002&lt;BR /&gt;
x 22 2003&lt;BR /&gt;
x 22 2001&lt;BR /&gt;
z 33 2002&lt;BR /&gt;
v 33 2002&lt;BR /&gt;
b 14 2005&lt;BR /&gt;
w 22 2001&lt;BR /&gt;
x 22 2002&lt;BR /&gt;
x 22 2003&lt;BR /&gt;
x 22 2001&lt;BR /&gt;
z 33 2002&lt;BR /&gt;
v 33 2002&lt;BR /&gt;
b 14 2005&lt;BR /&gt;
w 22 2001&lt;BR /&gt;
x 22 2002&lt;BR /&gt;
x 22 2003&lt;BR /&gt;
x 22 2001&lt;BR /&gt;
z 33 2002&lt;BR /&gt;
v 33 2002&lt;BR /&gt;
b 14 2005&lt;BR /&gt;
w 22 2001&lt;BR /&gt;
x 22 2002&lt;BR /&gt;
x 22 2003&lt;BR /&gt;
x 22 2001&lt;BR /&gt;
z 33 2002&lt;BR /&gt;
v 33 2002&lt;BR /&gt;
b 14 2005&lt;BR /&gt;
w 22 2001&lt;BR /&gt;
x 22 2002&lt;BR /&gt;
x 22 2003&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table temp as&lt;BR /&gt;
 select *,count(*) as n&lt;BR /&gt;
  from dataset&lt;BR /&gt;
   group by year,industry&lt;BR /&gt;
    having calculated n ge 10&lt;BR /&gt;
     order by year,industry&lt;BR /&gt;
     ;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Fri, 04 Mar 2011 03:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19614#M3999</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-04T03:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19615#M4000</link>
      <description>Many thanks</description>
      <pubDate>Fri, 04 Mar 2011 11:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19615#M4000</guid>
      <dc:creator>q1234</dc:creator>
      <dc:date>2011-03-04T11:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19616#M4001</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
After I did the match I found that one firms from the matched portfolio matched with more than one frms from the even firmst. For example, the firms k match with many firms. So can you help me to modify the code that I do not have the same firms from the matched portfolio match with many frim from the event firsm&lt;BR /&gt;
the event firms     the matched portfolio&lt;BR /&gt;
x                    k&lt;BR /&gt;
z                    c&lt;BR /&gt;
b                    k&lt;BR /&gt;
g                    k&lt;BR /&gt;
v                    n&lt;BR /&gt;
&lt;BR /&gt;
The code&lt;BR /&gt;
a: the event firms&lt;BR /&gt;
b: the firms which have the matched&lt;BR /&gt;
&lt;BR /&gt;
proc sql &lt;BR /&gt;
; create table rem.portfolio1&lt;BR /&gt;
as  select *   from a ,b&lt;BR /&gt;
where ipo_year=_year and sic=_sic and &lt;BR /&gt;
(roa between .9*_roa and 1.1*_roa) &lt;BR /&gt;
&lt;BR /&gt;
; create table rem.portfolio2 &lt;BR /&gt;
as  select *,min(abs(roa - _roa)) as closest   from rem.portfolio1&lt;BR /&gt;
group by firms_id &lt;BR /&gt;
having abs(roa - _roa) eq calculated closest&lt;BR /&gt;
order by firms_id   ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Many thanks</description>
      <pubDate>Wed, 09 Mar 2011 11:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19616#M4001</guid>
      <dc:creator>q1234</dc:creator>
      <dc:date>2011-03-09T11:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19617#M4002</link>
      <description>Hi.&lt;BR /&gt;
You found "one firms from the matched portfolio matched with more than one frms from the even firmst"  ,&lt;BR /&gt;
that is because k firms has the most close distance with several firms from event firms,&lt;BR /&gt;
I do not know which k firms you do not need, Do you have a criteria?&lt;BR /&gt;
[pre]&lt;BR /&gt;
x k  &amp;lt;---------- you want this k company ?&lt;BR /&gt;
z c&lt;BR /&gt;
b k  &amp;lt;---------- you want this k company ? &lt;BR /&gt;
g k  &amp;lt;---------- you want this k company ?&lt;BR /&gt;
v n&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Without  logic to keep which k firm, It is hard to recommend.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 10 Mar 2011 05:04:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19617#M4002</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-10T05:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19618#M4003</link>
      <description>Hi.&lt;BR /&gt;
I think it again.&lt;BR /&gt;
Maybe you can exchange the position of table a and table b.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
select * from &lt;B&gt;b ,a&lt;/B&gt;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
But, I do not know the result is whether what you want.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 10 Mar 2011 08:37:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19618#M4003</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-10T08:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19619#M4004</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I have changed the tables' position, but that does not make any difference on the output. Actually, what I need exactly as to use the firms K just for one time and does not matter to which one it will be matched. So it is like to write code to restrict the use of each firms in the match portfolio just for one time.&lt;BR /&gt;
&lt;BR /&gt;
Many thanks</description>
      <pubDate>Thu, 10 Mar 2011 15:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19619#M4004</guid>
      <dc:creator>q1234</dc:creator>
      <dc:date>2011-03-10T15:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19620#M4005</link>
      <description>Hi.&lt;BR /&gt;
I think you have duplicate obs. try these.&lt;BR /&gt;
Can you post some example code and data?&lt;BR /&gt;
&lt;BR /&gt;
You said:&lt;BR /&gt;
&amp;gt;I need to match each company from the event to one company from the control, where both of them should have the same year and industry, and the size for the event companies should between 130% and 70% of the match companies’ size.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
That means k firm from match is possible to match multiple firm from event.Best to post some example code and data , and explain which k firm you do not want.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data event;&lt;BR /&gt;
input firm $ year industry size ratio;&lt;BR /&gt;
datalines;&lt;BR /&gt;
x 2000 20 100 1.1&lt;BR /&gt;
y 1999 25 250 .9&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data match;&lt;BR /&gt;
input _firm $ _year _industry _size _ratio;&lt;BR /&gt;
datalines;&lt;BR /&gt;
A 2000 20 100 1.2&lt;BR /&gt;
A 2000 20 100 1.2&lt;BR /&gt;
J 1999 25 250 .4&lt;BR /&gt;
K 2000 20 100 1.4&lt;BR /&gt;
L 1999 25 250 .9&lt;BR /&gt;
T 2000 20 100 1.8&lt;BR /&gt;
R 1999 25 250 .2&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql ;&lt;BR /&gt;
 create table portfolio1 as&lt;BR /&gt;
  select *&lt;BR /&gt;
   from event,match&lt;BR /&gt;
    where year=_year and industry=_industry and&lt;BR /&gt;
          (size between .7*_size and 1.3*_size)&lt;BR /&gt;
        ;&lt;BR /&gt;
&lt;BR /&gt;
 create table portfolio2 as&lt;BR /&gt;
  select &lt;B&gt;distinct &lt;/B&gt;*,min(abs(ratio - _ratio)) as closest&lt;BR /&gt;
   from portfolio1&lt;BR /&gt;
     group by firm&lt;BR /&gt;
        having abs(ratio - _ratio) eq calculated closest  &lt;BR /&gt;
         order by firm&lt;BR /&gt;
    ; &lt;BR /&gt;
     &lt;BR /&gt;
&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Fri, 11 Mar 2011 01:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19620#M4005</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-11T01:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: matching event sample to control sample but using any control</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19621#M4006</link>
      <description>Hi.&lt;BR /&gt;
I think maybe I understand what you mean.&lt;BR /&gt;
You need to exchange the position of these two tables,&lt;BR /&gt;
and change the group by variable.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql ; &lt;BR /&gt;
create table portfolio1 as  &lt;BR /&gt;
   select *   from &lt;B&gt;match,event  &lt;/B&gt; &lt;BR /&gt;
     where year=_year and industry=_industry and &lt;BR /&gt;
         (size between .7*_size and 1.3*_size)        ; &lt;BR /&gt;
&lt;BR /&gt;
create table portfolio2 as  &lt;BR /&gt;
select *,min(abs(ratio - _ratio)) as closest   &lt;BR /&gt;
  from portfolio1    &lt;BR /&gt;
   group by &lt;B&gt;_firm       &lt;/B&gt; &lt;BR /&gt;
     having abs(ratio - _ratio) eq calculated closest          &lt;BR /&gt;
     order by &lt;B&gt;_firm   &lt;/B&gt; ;     quit;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Ksharp</description>
      <pubDate>Fri, 11 Mar 2011 02:40:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/matching-event-sample-to-control-sample-but-using-any-control/m-p/19621#M4006</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-03-11T02:40:13Z</dc:date>
    </item>
  </channel>
</rss>

