<?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: Variable creation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/228559#M41290</link>
    <description>&lt;P&gt;Thanks a lot for your reply. I will implement on my entire dataset.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Oct 2015 00:33:55 GMT</pubDate>
    <dc:creator>factorhedge</dc:creator>
    <dc:date>2015-10-06T00:33:55Z</dc:date>
    <item>
      <title>Variable creation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/227790#M41080</link>
      <description>&lt;P&gt;Hi I was wondering if anyone could help me to create the variable(shown below) for my project&lt;/P&gt;
&lt;P&gt;I have the dataset as shown in my attachment , it is not orginal data but the variables are similar&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Variables&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CEO_Ind = 1 if the Director_name is CEO , 0 otherwise&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ind_indicator = 1 if Director_name is independent , 0 otherwise&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These two indicator variables are mutually exclusive for e.g. if&amp;nbsp;&lt;SPAN&gt;CEO_Ind = 1 then by definition&amp;nbsp;Ind_indicator =&amp;nbsp;0. However there could be non independent and non CEO i.e both the indicators will have 0&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Variable I need is&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For Firm_code 11 if the Director_name A also appears in any other company for instance Firm_code 265 along with any of other Directors that also appear in Firm_code 11 "within the same year" then Interlocking = 1 else Interlocking = 0&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For instance as per the attached spreadsheet&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For year = 2006&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For FIRM_CODE 11 , Director A is accompanied by Directors B and C in 2006&amp;nbsp;and Directors A and C also appear for FIRM_CODE 265 so the interlocking variable for FIRM_CODE 11 will be 1 , 0 otherwise&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly for year = 2007&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For FIRM_CODE 11 , Director A is accompanied by Directors B and C in 2007&amp;nbsp;and Directors A and B&amp;nbsp;also appear for FIRM_CODE 265 &lt;SPAN&gt;so the interlocking variable for FIRM_CODE 11 will be 1 , 0 otherwise&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/11981i1F251AE53FBBCB35/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Interlocking.PNG" title="Interlocking.PNG" /&gt;</description>
      <pubDate>Wed, 30 Sep 2015 00:17:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/227790#M41080</guid>
      <dc:creator>factorhedge</dc:creator>
      <dc:date>2015-09-30T00:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Variable creation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/227792#M41081</link>
      <description>&lt;P&gt;Thanks for your question.&lt;/P&gt;
&lt;P&gt;I've moved your question to this topical forum as more experts will be able to help here.&lt;BR /&gt; &lt;BR /&gt;Best,&lt;BR /&gt;&lt;BR /&gt;Lainie&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2015 01:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/227792#M41081</guid>
      <dc:creator>LainieH</dc:creator>
      <dc:date>2015-09-30T01:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Variable creation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/227800#M41084</link>
      <description>&lt;P&gt;Please post example data as text, next time. I changed your data slightly so that year=2007 is NOT interlocked&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input firm_code year director$;
datalines;
11 2006 A
11 2006 B
11 2006 C
11 2007 A
11 2007 B
11 2007 C
11 2008 A
11 2008 B
11 2008 C
11 2008 D
265 2006 X
265 2006 A
265 2006 C
265 2007 X
265 2007 A
265 2007 D
265 2008 X
265 2008 A
265 2008 B
265 2008 C
265 2009 D
;

proc sql;
create table interlocks as
select year, firm_code_a, firm_code_b
from (
    select a.year, a.firm_code as firm_code_a, b.firm_code as firm_code_b
    from have as a inner join have as b on
        a.year=b.year and 
        a.director=b.director and 
        a.firm_code ne b.firm_code
)
group by year, firm_code_a, firm_code_b
having count(*) &amp;gt; 1;
create table want as
select a.*, b.year is not missing as interlock
from 
    (select distinct year, firm_code from have) as a left join 
    interlocks as b on 
        a.year=b.year and 
        a.firm_code=b.firm_code_a;
select * from want;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2015 02:57:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/227800#M41084</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2015-09-30T02:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Variable creation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/228559#M41290</link>
      <description>&lt;P&gt;Thanks a lot for your reply. I will implement on my entire dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Oct 2015 00:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Variable-creation/m-p/228559#M41290</guid>
      <dc:creator>factorhedge</dc:creator>
      <dc:date>2015-10-06T00:33:55Z</dc:date>
    </item>
  </channel>
</rss>

