<?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: Connect two databases and to do the selection in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/Connect-two-databases-and-to-do-the-selection/m-p/199506#M2793</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you considered using a SAS macro variable to pass list of values? It can be a very efficient technique.Something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;select quote(variable_name) into :value_list separated by ' ' from libname.source_table ; /* quote() may not be needed */&lt;/P&gt;&lt;P&gt;quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;value_list ;&amp;nbsp; /* For checking */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then query the other database:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from other_table where variable_name in ("&amp;amp;value_list") ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Jul 2015 13:36:54 GMT</pubDate>
    <dc:creator>acfarrer</dc:creator>
    <dc:date>2015-07-09T13:36:54Z</dc:date>
    <item>
      <title>Connect two databases and to do the selection</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Connect-two-databases-and-to-do-the-selection/m-p/199504#M2791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys, &lt;/P&gt;&lt;P&gt;Now I have 40 values for one variable (character). I would like to use these 40 values to generate a list and apply this list in another database to select certain observation. For example, I have 40 names of dog breeds in one database (A) and another database (B) contains information of dog id, breed name, and dog weight. What I need to do is to choose the dog ID from the second database (B) whose breed name appear in the database A.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;My plan is to create a character list with the function concatenation and then I got stuck. How should I introduce this list into the database A? Does anybody do something similar and give me some suggestions? Any suggestion is appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Fawkes &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 11:11:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Connect-two-databases-and-to-do-the-selection/m-p/199504#M2791</guid>
      <dc:creator>Fawkes</dc:creator>
      <dc:date>2015-07-09T11:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Connect two databases and to do the selection</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Connect-two-databases-and-to-do-the-selection/m-p/199505#M2792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look at the documentation on fedsql: &lt;A href="http://support.sas.com/documentation/cdl/en/fedsqlref/67364/HTML/default/viewer.htm#titlepage.htm" title="http://support.sas.com/documentation/cdl/en/fedsqlref/67364/HTML/default/viewer.htm#titlepage.htm"&gt;http://support.sas.com/documentation/cdl/en/fedsqlref/67364/HTML/default/viewer.htm#titlepage.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Although that is probably overkill.&amp;nbsp; Just connect to each database separately, and extract the data in SAS.&amp;nbsp; Then in SAS do your processing:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connect to ...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table a as select * from connection... (select...);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diconnect from ...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connect to ...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table b as ...;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; disconnect...;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;data xyz;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...;&amp;nbsp;&amp;nbsp; /* Do processing */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 11:56:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Connect-two-databases-and-to-do-the-selection/m-p/199505#M2792</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-09T11:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Connect two databases and to do the selection</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Connect-two-databases-and-to-do-the-selection/m-p/199506#M2793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you considered using a SAS macro variable to pass list of values? It can be a very efficient technique.Something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;/P&gt;&lt;P&gt;select quote(variable_name) into :value_list separated by ' ' from libname.source_table ; /* quote() may not be needed */&lt;/P&gt;&lt;P&gt;quit ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put &amp;amp;value_list ;&amp;nbsp; /* For checking */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then query the other database:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select * from other_table where variable_name in ("&amp;amp;value_list") ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jul 2015 13:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Connect-two-databases-and-to-do-the-selection/m-p/199506#M2793</guid>
      <dc:creator>acfarrer</dc:creator>
      <dc:date>2015-07-09T13:36:54Z</dc:date>
    </item>
  </channel>
</rss>

