<?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: Unbalanced to Balanced Panel Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unbalanced-to-Balanced-Panel-Data/m-p/733185#M228483</link>
    <description>&lt;P&gt;It would be helpful if you could provide some sample data for these questions.&lt;/P&gt;
&lt;P&gt;Now, in the following code, 16 rows from 1997 to 2012 are extracted as the key.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create test data */
data have;
  length cusip $10 year 8;
  do cusip='A','C';
    do year=1997 to 2012;
      output;
    end;
  end;
  cusip='B';
  do year=1997 to 2000;
    output;
  end;
  do cusip='D';
    do year=1998 to 2013;
      output;
    end;
  end;
run;

/* extract */
proc sort data=have nodupkey;
  by cusip year;
  where 1997&amp;lt;=year&amp;lt;=2012;
run;
proc freq data=have noprint;
  table cusip / out=freq(where=(COUNT=16));
run;
proc sql;
  create table want as
    select have.* from have, freq
    where have.cusip=freq.cusip
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 13 Apr 2021 02:35:37 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2021-04-13T02:35:37Z</dc:date>
    <item>
      <title>Unbalanced to Balanced Panel Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unbalanced-to-Balanced-Panel-Data/m-p/733149#M228468</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an unbalanced panel data set where my data is from 1997 to 2012 (denoted by year). However, some firms (denoted by cusip) does not exist for all years. Therefore I want to drop those firms. I want to keep only firms where I have data from 1997 to 2012. Any suggestions on how to do that? I would really appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 00:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unbalanced-to-Balanced-Panel-Data/m-p/733149#M228468</guid>
      <dc:creator>therock</dc:creator>
      <dc:date>2021-04-13T00:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Unbalanced to Balanced Panel Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unbalanced-to-Balanced-Panel-Data/m-p/733184#M228482</link>
      <description>&lt;P&gt;How many such customers do you expect?&lt;/P&gt;
&lt;P&gt;Something like this (untested as no test data was provided)?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; 
  create table DROPCUS as 
  select CUSIP 
  from TABLE 
  group by CUSIP 
  having count(unique YEAR) &amp;lt; 16 ;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 02:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unbalanced-to-Balanced-Panel-Data/m-p/733184#M228482</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-04-13T02:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unbalanced to Balanced Panel Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unbalanced-to-Balanced-Panel-Data/m-p/733185#M228483</link>
      <description>&lt;P&gt;It would be helpful if you could provide some sample data for these questions.&lt;/P&gt;
&lt;P&gt;Now, in the following code, 16 rows from 1997 to 2012 are extracted as the key.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create test data */
data have;
  length cusip $10 year 8;
  do cusip='A','C';
    do year=1997 to 2012;
      output;
    end;
  end;
  cusip='B';
  do year=1997 to 2000;
    output;
  end;
  do cusip='D';
    do year=1998 to 2013;
      output;
    end;
  end;
run;

/* extract */
proc sort data=have nodupkey;
  by cusip year;
  where 1997&amp;lt;=year&amp;lt;=2012;
run;
proc freq data=have noprint;
  table cusip / out=freq(where=(COUNT=16));
run;
proc sql;
  create table want as
    select have.* from have, freq
    where have.cusip=freq.cusip
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 02:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unbalanced-to-Balanced-Panel-Data/m-p/733185#M228483</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-04-13T02:35:37Z</dc:date>
    </item>
  </channel>
</rss>

