<?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: proc sql terminology in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412531#M26540</link>
    <description>&lt;P&gt;The IDs from the first query are a subset of the IDs kept by the second query since the first query selects only IDs from the second query that are also present in table dbname.clinical.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Nov 2017 22:48:57 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2017-11-10T22:48:57Z</dc:date>
    <item>
      <title>proc sql terminology</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412372#M26516</link>
      <description>&lt;P&gt;I am using proc sql to combine datasets.&amp;nbsp; What is the theoretical difference (if any) in using these two codes with respect to the patient IDs kept?&amp;nbsp;&amp;nbsp;Do they both only keep the patient IDs from the first dataset and match to&amp;nbsp;the identical patient IDs in the second?&amp;nbsp; The goal of both is to use the a dataset and then only obtain the files with the same patient ID showing up in b.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mart_TS.missmedical &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.patid, a.index_dt, a.preg_dt, &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;b.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;*&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mart_TS.outcomemiss a, dbname.clinical(keep=patid eventdate medcode) b&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.patid=b.patid &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;order&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a.patid, b.medcode;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mart_TS.outcomemiss &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; *&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mart_tmp.ptlist3bdedup &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;where&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; patid &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;not&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;in&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; patid &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; mart_tmp.ptlist4bdedup);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:06:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412372#M26516</guid>
      <dc:creator>Dsquared</dc:creator>
      <dc:date>2017-11-10T15:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql terminology</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412388#M26518</link>
      <description>&lt;P&gt;Try it and compare the results. See Maxim 4.&lt;/P&gt;
&lt;P&gt;If the results are equal, check real and cpu times in the log to determine which method is more efficient.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:40:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412388#M26518</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-10T15:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql terminology</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412394#M26521</link>
      <description>&lt;PRE&gt;proc sql;
	Select a.id, a.var2,  b.*
		From tablea a, tableb b
			Where a.id = b.id;&lt;/PRE&gt;&lt;P&gt;Above performs an ‘Inner join’ of all records in a and b, matched on id, with columns in select list from both tables and potentially multiple rows for a single id from tablea if multiple matches in tableb (i.e. one to many relationship)&lt;/P&gt;&lt;PRE&gt;proc sql;
	Select * 
		From tablea 
			where id in 
				(select distinct id from tableb);&lt;/PRE&gt;&lt;P&gt;Whereas, latter returns all records from tablea with an id that exists in tableb (or the complement, i.e. returns if doesn’t exist, if NOT IN used).&amp;nbsp; WHERE IN (sub-query) does not join the tables and you cannot select other variables from tableb in your select list.&amp;nbsp; Also, if you have a one to many relationship between the two tables, using a sub-query will only return one row per record from tablea.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 15:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412394#M26521</guid>
      <dc:creator>Jeremy_Browne</dc:creator>
      <dc:date>2017-11-10T15:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql terminology</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412531#M26540</link>
      <description>&lt;P&gt;The IDs from the first query are a subset of the IDs kept by the second query since the first query selects only IDs from the second query that are also present in table dbname.clinical.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 22:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412531#M26540</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-10T22:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql terminology</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412532#M26541</link>
      <description>&lt;P&gt;Note, the first query might generate more records than you expect if there are multiple records per ID in dbname.clinical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second query doesn't have that problem (even without the distinct keyword) but it doesn't allow you to bring in fields from the second table.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Nov 2017 22:54:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-terminology/m-p/412532#M26541</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-11-10T22:54:55Z</dc:date>
    </item>
  </channel>
</rss>

