<?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: Creating a table from two datasets but conditional on one dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745195#M233554</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select * from dsfdata where permo in
         (select distinct permno from uniquepermno);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Jun 2021 14:27:02 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2021-06-02T14:27:02Z</dc:date>
    <item>
      <title>Creating a table from two datasets but conditional on one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745184#M233551</link>
      <description>&lt;P&gt;I have two datasets. The first dataset, crsp.dsf, includes daily stock returns for multiple securities. My second dataset, uniquepermnos, includes a list of securities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to filter crsp.dsf for the securities in my uniquepermnos.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the uniquepermno dataset&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	
1	10002	
2	10026	
3	10032	
4	10044	
5	10051	
6	10065	
7	10078&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the dsfdata.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	permno date ret
1	10026	19860204	C	
2	10026	19860205	0.042553	
3	10026	19860206	-0.034014	
4	10026	19860207	-0.014085	
5	10026	19860210	0.014286	
6	10026	19860211	-0.021127	
7	10026	19860212	-0.003597	
8	10026	19860213	-0.021661	
9	10026	19860214	0.003690	
10	10026	19860218	0.044118&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the example code below. As you can see, it is only picking up 2 permnos. I want it to pick up all permnos in the uniquepermnos dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dsfdata;&lt;/P&gt;&lt;P&gt;set dsfdata;&lt;BR /&gt;if permno=10026 or permno=10032;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 14:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745184#M233551</guid>
      <dc:creator>Mistletoad</dc:creator>
      <dc:date>2021-06-02T14:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from two datasets but conditional on one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745194#M233553</link>
      <description>&lt;P&gt;1. Merge and use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/ledsoptsref/n1p1o2dsuc465nn198ovwdrj9mvy.htm" target="_self"&gt;IN data set option&lt;/A&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge dsfdata (in=dsf) uniquepermno (in=unique);
by permno;
if unique;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. SQL&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select * from dsfdata
where permno in (select permno from uniquepermno);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;There are many other ways including a SQL left join, hash, formats or even a data step and temporary array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/340343"&gt;@Mistletoad&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two datasets. The first dataset, crsp.dsf, includes daily stock returns for multiple securities. My second dataset, uniquepermnos, includes a list of securities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to filter crsp.dsf for the securities in my uniquepermnos.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the uniquepermno dataset&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	
1	10002	
2	10026	
3	10032	
4	10044	
5	10051	
6	10065	
7	10078&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is the dsfdata.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	permno date ret
1	10026	19860204	C	
2	10026	19860205	0.042553	
3	10026	19860206	-0.034014	
4	10026	19860207	-0.014085	
5	10026	19860210	0.014286	
6	10026	19860211	-0.021127	
7	10026	19860212	-0.003597	
8	10026	19860213	-0.021661	
9	10026	19860214	0.003690	
10	10026	19860218	0.044118&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This is the example code below. As you can see, it is only picking up 2 permnos. I want it to pick up all permnos in the uniquepermnos dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data dsfdata;&lt;/P&gt;
&lt;P&gt;set dsfdata;&lt;BR /&gt;if permno=10026 or permno=10032;&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 14:25:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745194#M233553</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-02T14:25:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from two datasets but conditional on one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745195#M233554</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    create table want as select * from dsfdata where permo in
         (select distinct permno from uniquepermno);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Jun 2021 14:27:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745195#M233554</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-06-02T14:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from two datasets but conditional on one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745208#M233560</link>
      <description>&lt;P&gt;Hash:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set dsfdata;
if _n_ = 1
then do;
  declare hash unique (dataset:"uniquepermno");
  unique.definekey("permno");
  unique.definedone();
end;
if unique.check() = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Jun 2021 15:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-from-two-datasets-but-conditional-on-one/m-p/745208#M233560</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-02T15:04:24Z</dc:date>
    </item>
  </channel>
</rss>

