<?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 keep only common observations in the same period (year) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393055#M94637</link>
    <description>&lt;P&gt;Hello Genius !&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need Your help. It's my first participation here. In fact Im a beginner and I'm learning SAS. I have data grouped in columns and associated with years.&lt;/P&gt;&lt;P&gt;just like this form:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                     
     Var                year
                                  
    Tr1           2006                  
    Tr2           2006                         
    Tr3           2006
    Tr4           2006         
    Tr5           2006
    Tr6           2006
    Tr7           2006        


  Var                year
                                  
    Tr1           2007                                           
    Tr3           2007
    Tr4           2007         
    Tr5           2007
    Tr7           2007 

  Var                year
                                  
    Tr1           2008                                          
    Tr2           2008        
    Tr5           2008
    Tr6           2008
    Tr7           2008    
     &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want is to extract or determinate just the variables present in all tested years (the common ones) , like this example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  Var                year
                                  
    Tr1           2006                  
    Tr1           2007                         
    Tr1           2008
    Tr5           2006         
    Tr5           2007
    Tr5           2008
    Tr7           2006 
    Tr7           2007
    Tr7           2008&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Im working on thousands of data from 2006 to 2016, and I want to keep just the data present in all&amp;nbsp;the tested years. i WISH my request is enough clear to get the right solution. Thank you for your time and help. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Sep 2017 22:11:12 GMT</pubDate>
    <dc:creator>SAHAR17</dc:creator>
    <dc:date>2017-09-04T22:11:12Z</dc:date>
    <item>
      <title>keep only common observations in the same period (year)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393055#M94637</link>
      <description>&lt;P&gt;Hello Genius !&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need Your help. It's my first participation here. In fact Im a beginner and I'm learning SAS. I have data grouped in columns and associated with years.&lt;/P&gt;&lt;P&gt;just like this form:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                                     
     Var                year
                                  
    Tr1           2006                  
    Tr2           2006                         
    Tr3           2006
    Tr4           2006         
    Tr5           2006
    Tr6           2006
    Tr7           2006        


  Var                year
                                  
    Tr1           2007                                           
    Tr3           2007
    Tr4           2007         
    Tr5           2007
    Tr7           2007 

  Var                year
                                  
    Tr1           2008                                          
    Tr2           2008        
    Tr5           2008
    Tr6           2008
    Tr7           2008    
     &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want is to extract or determinate just the variables present in all tested years (the common ones) , like this example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  Var                year
                                  
    Tr1           2006                  
    Tr1           2007                         
    Tr1           2008
    Tr5           2006         
    Tr5           2007
    Tr5           2008
    Tr7           2006 
    Tr7           2007
    Tr7           2008&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Im working on thousands of data from 2006 to 2016, and I want to keep just the data present in all&amp;nbsp;the tested years. i WISH my request is enough clear to get the right solution. Thank you for your time and help. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 22:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393055#M94637</guid>
      <dc:creator>SAHAR17</dc:creator>
      <dc:date>2017-09-04T22:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: keep only common observations in the same period (year)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393058#M94638</link>
      <description>&lt;P&gt;I can't test this right now, but it looks like it should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql&amp;nbsp;noprint;&lt;/P&gt;
&lt;P&gt;create table want as select * from have&lt;/P&gt;
&lt;P&gt;groupby var&lt;/P&gt;
&lt;P&gt;where count(distinct year) = 3;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 22:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393058#M94638</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-04T22:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: keep only common observations in the same period (year)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393082#M94644</link>
      <description>&lt;P&gt;1. Can you have&amp;nbsp;duplicate entries? ie VAR &amp;amp; TRT are the same&lt;/P&gt;
&lt;P&gt;2. Are the periods the same, ie if I have 3 distinct years will the all be the same or could it be 2004-2006 and 2005-2007?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 01:10:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393082#M94644</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-05T01:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: keep only common observations in the same period (year)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393092#M94650</link>
      <description>&lt;P&gt;Assuming all your data is in dataset &lt;STRONG&gt;have&lt;/STRONG&gt;, this should do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select unique
    var, 
    year
from have
group by var
having count(distinct year) = (select count(distinct year) from have)
order by var, year;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 03:49:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393092#M94650</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-09-05T03:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: keep only common observations in the same period (year)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393140#M94663</link>
      <description>&lt;P&gt;1. you mean var and year? var is the variable assiociated to year , it couldn't be the same because year= (2006 until 2016)&amp;nbsp;&lt;/P&gt;&lt;P&gt;var = different entires.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.for each year , there is different var , I want to know which var existent in all the period from 2006 to 2016 .For Example : &amp;nbsp;2006 could contain Tr1 Tr2 Tr3 , and 2007 contains Tr1 Tr2 , so I want to have a table showing me That Tr1 and Tr2 are existent in 2006 and 2007.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 10:07:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393140#M94663</guid>
      <dc:creator>SAHAR17</dc:creator>
      <dc:date>2017-09-05T10:07:43Z</dc:date>
    </item>
    <item>
      <title>Re: keep only common observations in the same period (year)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393161#M94667</link>
      <description>&lt;P&gt;it works! Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 11:33:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393161#M94667</guid>
      <dc:creator>SAHAR17</dc:creator>
      <dc:date>2017-09-05T11:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: keep only common observations in the same period (year)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393162#M94668</link>
      <description>&lt;P&gt;I haven't tested it yet , but I think it's similar to the code given by PG stat , Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 11:35:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keep-only-common-observations-in-the-same-period-year/m-p/393162#M94668</guid>
      <dc:creator>SAHAR17</dc:creator>
      <dc:date>2017-09-05T11:35:53Z</dc:date>
    </item>
  </channel>
</rss>

