<?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: Need code to create a new sample from the original sample in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-code-to-create-a-new-sample-from-the-original-sample/m-p/141539#M261571</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input TIc $ year ceo$;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;A 2003 Tim&lt;/P&gt;&lt;P&gt;A 2004 Tim&lt;/P&gt;&lt;P&gt;A 2005 Tim&lt;/P&gt;&lt;P&gt;A 2006 Tim&lt;/P&gt;&lt;P&gt;A 2007 Tim&lt;/P&gt;&lt;P&gt;A 2008 John&lt;/P&gt;&lt;P&gt;A 2009 John&lt;/P&gt;&lt;P&gt;A 2010 John&lt;/P&gt;&lt;P&gt;A 2011 John &lt;/P&gt;&lt;P&gt;A 2012 John&lt;/P&gt;&lt;P&gt;A 2013 John&lt;/P&gt;&lt;P&gt;B 2003 Lin&lt;/P&gt;&lt;P&gt;B 2004 Lin&lt;/P&gt;&lt;P&gt;B 2005 Lin&lt;/P&gt;&lt;P&gt;B 2006 Sam&lt;/P&gt;&lt;P&gt;B 2007 Sam&lt;/P&gt;&lt;P&gt;B 2008 Sam&lt;/P&gt;&lt;P&gt;B 2009 Sam&lt;/P&gt;&lt;P&gt;B 2010 Sam&lt;/P&gt;&lt;P&gt;B 2011 Sam&lt;/P&gt;&lt;P&gt;B 2012 Sam&lt;/P&gt;&lt;P&gt;B 2013 Sam&lt;/P&gt;&lt;P&gt;C 2003 Dan&lt;/P&gt;&lt;P&gt;C 2004 Dan&lt;/P&gt;&lt;P&gt;C 2005 Dan&lt;/P&gt;&lt;P&gt;C 2006 Dan&lt;/P&gt;&lt;P&gt;C 2007 Dan&lt;/P&gt;&lt;P&gt;C 2008 Dan&lt;/P&gt;&lt;P&gt;C 2009 Dan&lt;/P&gt;&lt;P&gt;C 2010 Dan&lt;/P&gt;&lt;P&gt;C 2011 Jack&lt;/P&gt;&lt;P&gt;C 2012 Jack&lt;/P&gt;&lt;P&gt;C 2013 Jack&lt;/P&gt;&lt;P&gt;D 2003 Ali&lt;/P&gt;&lt;P&gt;D 2004 Ali&lt;/P&gt;&lt;P&gt;D 2005 Ali&lt;/P&gt;&lt;P&gt;D 2006 Ali&lt;/P&gt;&lt;P&gt;D 2007 Bill&lt;/P&gt;&lt;P&gt;D 2008 Bill&lt;/P&gt;&lt;P&gt;D 2009 Bill&lt;/P&gt;&lt;P&gt;D 2010 Frank&lt;/P&gt;&lt;P&gt;D 2011 Frank&lt;/P&gt;&lt;P&gt;D 2012 Frank&lt;/P&gt;&lt;P&gt;D 2013 Frank&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from have (where = (year between 2005 and 2012)) &lt;/P&gt;&lt;P&gt;WHERE TIC IN (select TIC from have (where = (year between 2007 and 2010)) &lt;/P&gt;&lt;P&gt;group by tic&lt;/P&gt;&lt;P&gt;having count(distinct ceo)=2) &lt;/P&gt;&lt;P&gt;group by tic&lt;/P&gt;&lt;P&gt;having count(distinct ceo)=2 &lt;/P&gt;&lt;P&gt;ORDER BY TIC, YEAR&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Mar 2014 19:41:30 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2014-03-12T19:41:30Z</dc:date>
    <item>
      <title>Need code to create a new sample from the original sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-code-to-create-a-new-sample-from-the-original-sample/m-p/141538#M261570</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 need your help in creating a new sample out of my current sample. My original sample has information about the firm (tic), year, and CEO. The sample period range from 2003 to 2013. I am trying to create a new sample that meets the following requirements:&lt;/P&gt;&lt;P&gt;1) the sample period should be from 2005 to 2012.&lt;/P&gt;&lt;P&gt;2) include only those firms that changed CEO only once and ceo should be changed between 2007 and 2010.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FOr instance if my original sample is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TIc year ceo&lt;/P&gt;&lt;P&gt;A 2003 Tim&lt;/P&gt;&lt;P&gt;A 2004 Tim&lt;/P&gt;&lt;P&gt;A 2005 Tim&lt;/P&gt;&lt;P&gt;A 2006 Tim&lt;/P&gt;&lt;P&gt;A 2007 Tim&lt;/P&gt;&lt;P&gt;A 2008 John&lt;/P&gt;&lt;P&gt;A 2009 John&lt;/P&gt;&lt;P&gt;A 2010 John&lt;/P&gt;&lt;P&gt;A 2011 John &lt;/P&gt;&lt;P&gt;A 2012 John&lt;/P&gt;&lt;P&gt;A 2013 John&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B 2003 Lin&lt;/P&gt;&lt;P&gt;B 2004 Lin&lt;/P&gt;&lt;P&gt;B 2005 Lin&lt;/P&gt;&lt;P&gt;B 2006 Sam&lt;/P&gt;&lt;P&gt;B 2007 Sam&lt;/P&gt;&lt;P&gt;B 2008 Sam&lt;/P&gt;&lt;P&gt;B 2009 Sam&lt;/P&gt;&lt;P&gt;B 2010 Sam&lt;/P&gt;&lt;P&gt;B 2011 Sam&lt;/P&gt;&lt;P&gt;B 2012 Sam&lt;/P&gt;&lt;P&gt;B 2013 Sam&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C 2003 Dan&lt;/P&gt;&lt;P&gt;C 2004 Dan&lt;/P&gt;&lt;P&gt;C 2005 Dan&lt;/P&gt;&lt;P&gt;C 2006 Dan&lt;/P&gt;&lt;P&gt;C 2007 Dan&lt;/P&gt;&lt;P&gt;C 2008 Dan&lt;/P&gt;&lt;P&gt;C 2009 Dan&lt;/P&gt;&lt;P&gt;C 2010 Dan&lt;/P&gt;&lt;P&gt;C 2011 Jack&lt;/P&gt;&lt;P&gt;C 2012 Jack&lt;/P&gt;&lt;P&gt;C 2013 Jack&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;D 2003 Ali&lt;/P&gt;&lt;P&gt;D 2004 Ali&lt;/P&gt;&lt;P&gt;D 2005 Ali&lt;/P&gt;&lt;P&gt;D 2006 Ali&lt;/P&gt;&lt;P&gt;D 2007 Bill&lt;/P&gt;&lt;P&gt;D 2008 Bill&lt;/P&gt;&lt;P&gt;D 2009 Bill&lt;/P&gt;&lt;P&gt;D 2010 Frank&lt;/P&gt;&lt;P&gt;D 2011 Frank&lt;/P&gt;&lt;P&gt;D 2012 Frank&lt;/P&gt;&lt;P&gt;D 2013 Frank&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IN the above example, A, B, and C has only one CEO change. However CEO was changed for firm B in 2006 and for firm C in 2011. So I dont want to keep B and C in my new sample. Firm D has two ceo change. So I want to exclude it too. In other words, my new sample should be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A 2005 Tim&lt;/P&gt;&lt;P&gt;A 2006 Tim&lt;/P&gt;&lt;P&gt;A 2007 Tim&lt;/P&gt;&lt;P&gt;A 2008 john&lt;/P&gt;&lt;P&gt;A 2009 John&lt;/P&gt;&lt;P&gt;A 2010 John&lt;/P&gt;&lt;P&gt;A 2011 John&lt;/P&gt;&lt;P&gt;A 2012 John&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would appreciate if someone can share&amp;nbsp; the code with me that will help me create the desired sample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;THank you &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 19:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-code-to-create-a-new-sample-from-the-original-sample/m-p/141538#M261570</guid>
      <dc:creator>shalmali</dc:creator>
      <dc:date>2014-03-12T19:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Need code to create a new sample from the original sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-code-to-create-a-new-sample-from-the-original-sample/m-p/141539#M261571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input TIc $ year ceo$;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;A 2003 Tim&lt;/P&gt;&lt;P&gt;A 2004 Tim&lt;/P&gt;&lt;P&gt;A 2005 Tim&lt;/P&gt;&lt;P&gt;A 2006 Tim&lt;/P&gt;&lt;P&gt;A 2007 Tim&lt;/P&gt;&lt;P&gt;A 2008 John&lt;/P&gt;&lt;P&gt;A 2009 John&lt;/P&gt;&lt;P&gt;A 2010 John&lt;/P&gt;&lt;P&gt;A 2011 John &lt;/P&gt;&lt;P&gt;A 2012 John&lt;/P&gt;&lt;P&gt;A 2013 John&lt;/P&gt;&lt;P&gt;B 2003 Lin&lt;/P&gt;&lt;P&gt;B 2004 Lin&lt;/P&gt;&lt;P&gt;B 2005 Lin&lt;/P&gt;&lt;P&gt;B 2006 Sam&lt;/P&gt;&lt;P&gt;B 2007 Sam&lt;/P&gt;&lt;P&gt;B 2008 Sam&lt;/P&gt;&lt;P&gt;B 2009 Sam&lt;/P&gt;&lt;P&gt;B 2010 Sam&lt;/P&gt;&lt;P&gt;B 2011 Sam&lt;/P&gt;&lt;P&gt;B 2012 Sam&lt;/P&gt;&lt;P&gt;B 2013 Sam&lt;/P&gt;&lt;P&gt;C 2003 Dan&lt;/P&gt;&lt;P&gt;C 2004 Dan&lt;/P&gt;&lt;P&gt;C 2005 Dan&lt;/P&gt;&lt;P&gt;C 2006 Dan&lt;/P&gt;&lt;P&gt;C 2007 Dan&lt;/P&gt;&lt;P&gt;C 2008 Dan&lt;/P&gt;&lt;P&gt;C 2009 Dan&lt;/P&gt;&lt;P&gt;C 2010 Dan&lt;/P&gt;&lt;P&gt;C 2011 Jack&lt;/P&gt;&lt;P&gt;C 2012 Jack&lt;/P&gt;&lt;P&gt;C 2013 Jack&lt;/P&gt;&lt;P&gt;D 2003 Ali&lt;/P&gt;&lt;P&gt;D 2004 Ali&lt;/P&gt;&lt;P&gt;D 2005 Ali&lt;/P&gt;&lt;P&gt;D 2006 Ali&lt;/P&gt;&lt;P&gt;D 2007 Bill&lt;/P&gt;&lt;P&gt;D 2008 Bill&lt;/P&gt;&lt;P&gt;D 2009 Bill&lt;/P&gt;&lt;P&gt;D 2010 Frank&lt;/P&gt;&lt;P&gt;D 2011 Frank&lt;/P&gt;&lt;P&gt;D 2012 Frank&lt;/P&gt;&lt;P&gt;D 2013 Frank&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from have (where = (year between 2005 and 2012)) &lt;/P&gt;&lt;P&gt;WHERE TIC IN (select TIC from have (where = (year between 2007 and 2010)) &lt;/P&gt;&lt;P&gt;group by tic&lt;/P&gt;&lt;P&gt;having count(distinct ceo)=2) &lt;/P&gt;&lt;P&gt;group by tic&lt;/P&gt;&lt;P&gt;having count(distinct ceo)=2 &lt;/P&gt;&lt;P&gt;ORDER BY TIC, YEAR&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 19:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-code-to-create-a-new-sample-from-the-original-sample/m-p/141539#M261571</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-03-12T19:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Need code to create a new sample from the original sample</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-code-to-create-a-new-sample-from-the-original-sample/m-p/141540#M261572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot for your prompt reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 23:07:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-code-to-create-a-new-sample-from-the-original-sample/m-p/141540#M261572</guid>
      <dc:creator>shalmali</dc:creator>
      <dc:date>2014-03-12T23:07:19Z</dc:date>
    </item>
  </channel>
</rss>

