<?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 problem in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61001#M17293</link>
    <description>yes this a solution. I however dreamed about a view that simply could be used from anywhere without having an other sql statement run prior to that.</description>
    <pubDate>Thu, 05 Aug 2010 16:42:01 GMT</pubDate>
    <dc:creator>niemannk</dc:creator>
    <dc:date>2010-08-05T16:42:01Z</dc:date>
    <item>
      <title>SQL problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/60999#M17291</link>
      <description>Hi,&lt;BR /&gt;
the following sql statement returns the string: mylib.tbl20&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select trim(libname)||'.'||trim(memname)&lt;BR /&gt;
from (select * from gmo.all_tables where date_=(select max(date_) from gmo.all_tables))&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
In gmo.all_tables I simply have a dataset (actually it is a view) on some tables that get created on daily basis.&lt;BR /&gt;
&lt;BR /&gt;
Now I want to select something from the table mylib.tbl20 (preferably as a view).&lt;BR /&gt;
&lt;BR /&gt;
This doesn't work&lt;BR /&gt;
proc sql;&lt;BR /&gt;
select * from (&lt;BR /&gt;
select trim(libname)||'.'||trim(memname)&lt;BR /&gt;
from (select * from gmo.all_tables where date_=(select max(date_) from gmo.all_tables))&lt;BR /&gt;
)&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
Anyway I can let SAS know the result of the embedded query is a table it should select from?? Thanks.</description>
      <pubDate>Thu, 05 Aug 2010 16:30:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/60999#M17291</guid>
      <dc:creator>niemannk</dc:creator>
      <dc:date>2010-08-05T16:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: SQL problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61000#M17292</link>
      <description>Create a macro variable in a preceding query and use that string-combination &lt;LIBREF&gt;.&lt;TABLE&gt;  in your subsequent query.  Have a look at using ":INTO" with your SELECT in PROC SQL, to generate a macro variable.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.&lt;BR /&gt;
&lt;BR /&gt;
Suggested Google advanced search, this topic / post:&lt;BR /&gt;
&lt;BR /&gt;
proc sql into macro variable site:sas.com&lt;/TABLE&gt;&lt;/LIBREF&gt;</description>
      <pubDate>Thu, 05 Aug 2010 16:34:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61000#M17292</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-08-05T16:34:15Z</dc:date>
    </item>
    <item>
      <title>Re: SQL problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61001#M17293</link>
      <description>yes this a solution. I however dreamed about a view that simply could be used from anywhere without having an other sql statement run prior to that.</description>
      <pubDate>Thu, 05 Aug 2010 16:42:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61001#M17293</guid>
      <dc:creator>niemannk</dc:creator>
      <dc:date>2010-08-05T16:42:01Z</dc:date>
    </item>
    <item>
      <title>Re: SQL problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61002#M17294</link>
      <description>Appears the SAS PROC SQL syntax doesn't support such constructs, to dynamically resolve the FROM.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 05 Aug 2010 17:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61002#M17294</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-08-05T17:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: SQL problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61003#M17295</link>
      <description>Your construct as such seems o.k. and it works for me (SAS 9.2) for sashelp.class:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  create view Vclass as&lt;BR /&gt;
    select *&lt;BR /&gt;
      from sashelp.class&lt;BR /&gt;
    ;&lt;BR /&gt;
&lt;BR /&gt;
  select * from (&lt;BR /&gt;
    select cats(sex,'.',age)&lt;BR /&gt;
      from (select * from Vclass where age=(select max(age) from Vclass))&lt;BR /&gt;
    )&lt;BR /&gt;
  ;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
What error do you get (post the log)?</description>
      <pubDate>Thu, 05 Aug 2010 21:18:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61003#M17295</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2010-08-05T21:18:46Z</dc:date>
    </item>
    <item>
      <title>Re: SQL problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61004#M17296</link>
      <description>thx Patrick, no error, but your inner query returns a table that the exterior query uses. I guess ssb is right. Whatever you create with a SELECT FROM is considered as a data table.</description>
      <pubDate>Fri, 06 Aug 2010 06:38:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61004#M17296</guid>
      <dc:creator>niemannk</dc:creator>
      <dc:date>2010-08-06T06:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: SQL problem</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61005#M17297</link>
      <description>would have been nice though...</description>
      <pubDate>Fri, 06 Aug 2010 06:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SQL-problem/m-p/61005#M17297</guid>
      <dc:creator>niemannk</dc:creator>
      <dc:date>2010-08-06T06:38:59Z</dc:date>
    </item>
  </channel>
</rss>

