<?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: SQL query: use the results from one query in a separate query in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181413#M46208</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I couldn't follow that. You have three datasets? bird1, bird_all, and bird_sub?&amp;nbsp; bird_sub is a subset of bird1, but bird1 is also a subset of bird_all?&lt;/P&gt;&lt;P&gt;You can join with the left or right options, which then keep on the data on the corresponding side of the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473691.htm" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473691.htm"&gt;Base SAS(R) 9.2 Procedures Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;See the sections on outer and inner joins which also go over left/right joins. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Feb 2014 01:13:32 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-02-21T01:13:32Z</dc:date>
    <item>
      <title>SQL query: use the results from one query in a separate query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181412#M46207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to subset a dataset (i.e. bird1) using the IDs (i.e. sys_id) that are returned from the query of a different dataset (i.e. bird_all).&lt;/P&gt;&lt;P&gt;So, I would like to create a new dataset (i.e. bird_sub which is a subset of bird1) that only contains the IDs that matched the following criteria in bird_all: year=2014 and primary_grp=1.&lt;/P&gt;&lt;P&gt;Can anyone show me the SQL code for this?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 00:59:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181412#M46207</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2014-02-21T00:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query: use the results from one query in a separate query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181413#M46208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I couldn't follow that. You have three datasets? bird1, bird_all, and bird_sub?&amp;nbsp; bird_sub is a subset of bird1, but bird1 is also a subset of bird_all?&lt;/P&gt;&lt;P&gt;You can join with the left or right options, which then keep on the data on the corresponding side of the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473691.htm" title="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473691.htm"&gt;Base SAS(R) 9.2 Procedures Guide&lt;/A&gt;&lt;/P&gt;&lt;P&gt;See the sections on outer and inner joins which also go over left/right joins. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 01:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181413#M46208</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-21T01:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query: use the results from one query in a separate query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181414#M46209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two datasets and I want to create a new a dataset.&lt;/P&gt;&lt;P&gt;The new dataset (i.e. bird_sub) will be a subset of bird1.&lt;/P&gt;&lt;P&gt;bird1 will be subset using values of sys_id.&lt;/P&gt;&lt;P&gt;These values need to be passed from bird_all using the following criteria: year=2014 and primary_grp=1.&lt;/P&gt;&lt;P&gt;What I don't want to do is proc print all the values of sys_id from bird_all that meet the criteria and then copy and paste these values into a where statement.&lt;/P&gt;&lt;P&gt;For example,&lt;/P&gt;&lt;P&gt;data bird_sub;&lt;/P&gt;&lt;P&gt;set bird1;&lt;/P&gt;&lt;P&gt;where sys_id in (1,2,5,9);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to create a SQL block of code that does this.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 01:25:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181414#M46209</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2014-02-21T01:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query: use the results from one query in a separate query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181415#M46210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Something like the following perhaps?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select * &lt;/P&gt;&lt;P&gt;from have&lt;/P&gt;&lt;P&gt;where sys_id in (select id from bird_all where year=2014 and primary_grp=1);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 01:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181415#M46210</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-02-21T01:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: SQL query: use the results from one query in a separate query</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181416#M46211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Feb 2014 17:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-query-use-the-results-from-one-query-in-a-separate-query/m-p/181416#M46211</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2014-02-21T17:25:29Z</dc:date>
    </item>
  </channel>
</rss>

