<?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 Question on SQL to SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50521#M13801</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically you wrap your query with PROC SQL and QUIT statements.&lt;/P&gt;&lt;P&gt;If you want to save the results you probably also need to add a CREATE TABLE xxxx or CREATE VIEW xxxx clause before the SELECT statement.&amp;nbsp; If you want to make a report then your probably do not want to use SQL code at all and instead want to look at PROC PRINT or PROC REPORT as you will be able to have much more control over the report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to run it totally in SAS then you will also need to convert the Oracle syntax to SAS syntax.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;TO_CHAR is an Oracle function to convert a date to character string. In SAS you would use the PUT() function.&lt;/LI&gt;&lt;LI&gt;Your column names have spaces in them.&amp;nbsp; You could set VALIDVARNAME=ANY and then convert the quote columns to SAS name litterals.&amp;nbsp; So "R Date" would be converted to "R Date"n.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you data is actually still in Oracle then you might want to use pass through SQL .&amp;nbsp; To do that your query is structured like this:&lt;/P&gt;&lt;P&gt;PROC SQL ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; CONNECT TO ORACLE&amp;nbsp; (.....);&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from connection to oracle (&lt;/P&gt;&lt;P&gt;**** put your Oracle SQL code here **** &lt;/P&gt;&lt;P&gt; );&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Feb 2012 16:00:31 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-02-09T16:00:31Z</dc:date>
    <item>
      <title>Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50517#M13797</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;&lt;/P&gt;&lt;P&gt;I was recently sent an SQL query and asked to run it in SAS. I am unsure on how to do this? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know there is a proc SQL command but I have never used it before...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any automated conversion?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 15:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50517#M13797</guid>
      <dc:creator>vomer</dc:creator>
      <dc:date>2012-02-09T15:33:20Z</dc:date>
    </item>
    <item>
      <title>Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50518#M13798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It would help if you post the query you were sent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 15:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50518#M13798</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-09T15:36:54Z</dc:date>
    </item>
    <item>
      <title>Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50519#M13799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a really long query but here is a snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select p.last_name "Last Name", &lt;/P&gt;&lt;P&gt;p.given_name "First Name", &lt;/P&gt;&lt;P&gt;p.identifier1 "Card", &lt;/P&gt;&lt;P&gt;r.id "RID", &lt;/P&gt;&lt;P&gt;TO_CHAR(r.referral_date, 'yyyy/mm/dd hh:mi:ss') "R Date", &lt;/P&gt;&lt;P&gt;ROUND(pt.unstable_interval / 86400000,1) "D Interval", &lt;/P&gt;&lt;P&gt;t1.name "Choice 1", &lt;/P&gt;&lt;P&gt;t2.name "Choice 2", &lt;/P&gt;&lt;P&gt;t3.name "Choice 3", &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 15:47:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50519#M13799</guid>
      <dc:creator>vomer</dc:creator>
      <dc:date>2012-02-09T15:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50520#M13800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depending upon how the rest of the query is written, it may run in SAS by just wrapping it within a proc sql statement.&amp;nbsp; e.g.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; your_entire_querry_ending_with_a_semi_colon&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS doesn't have a to_char function but, if the querry is designed as a passthru to Oracle, it will work anyhow.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 15:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50520#M13800</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-09T15:54:03Z</dc:date>
    </item>
    <item>
      <title>Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50521#M13801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basically you wrap your query with PROC SQL and QUIT statements.&lt;/P&gt;&lt;P&gt;If you want to save the results you probably also need to add a CREATE TABLE xxxx or CREATE VIEW xxxx clause before the SELECT statement.&amp;nbsp; If you want to make a report then your probably do not want to use SQL code at all and instead want to look at PROC PRINT or PROC REPORT as you will be able to have much more control over the report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to run it totally in SAS then you will also need to convert the Oracle syntax to SAS syntax.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;TO_CHAR is an Oracle function to convert a date to character string. In SAS you would use the PUT() function.&lt;/LI&gt;&lt;LI&gt;Your column names have spaces in them.&amp;nbsp; You could set VALIDVARNAME=ANY and then convert the quote columns to SAS name litterals.&amp;nbsp; So "R Date" would be converted to "R Date"n.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you data is actually still in Oracle then you might want to use pass through SQL .&amp;nbsp; To do that your query is structured like this:&lt;/P&gt;&lt;P&gt;PROC SQL ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; CONNECT TO ORACLE&amp;nbsp; (.....);&lt;/P&gt;&lt;P&gt;&amp;nbsp; select * from connection to oracle (&lt;/P&gt;&lt;P&gt;**** put your Oracle SQL code here **** &lt;/P&gt;&lt;P&gt; );&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 16:00:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50521#M13801</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-02-09T16:00:31Z</dc:date>
    </item>
    <item>
      <title>Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50522#M13802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, I could be wrong, but I think that with the secondary names enclosed in quotation marks the new name just becomes a variable label, thus setting validvarname=any wouldn't be necessary.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 16:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50522#M13802</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-09T16:05:14Z</dc:date>
    </item>
    <item>
      <title>Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50523#M13803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ignoring the other comments Tom made, which are valid and only replying here to the idea of using validvarname option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using SQL Pass-through as in Tom's post:&lt;/P&gt;&lt;P&gt;Using validvarname is not necessary when using just a select statement, like Tom said.&lt;/P&gt;&lt;P&gt;Using validvarname is also not necessary when using a create table however, if you do not mind in your case the spaces being converted to underscores.&amp;nbsp; I.e. "R Date" in Oracle would be "R_Date" in SAS with validvarname=V7 (default).&lt;/P&gt;&lt;P&gt;Using validvarname=any when using a create table will produce the identical expected variable names "R Date"n in SAS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When not using Pass-through as in Art's post:&lt;/P&gt;&lt;P&gt;In SAS this syntax would assign the quoted string as a lable and keep the variable name as it came from.&amp;nbsp; Just like Art said.&amp;nbsp; If you wanted to assign the labels as variable names instead you would need to use the as keyword and "VAR NAME"n to define the column name, using validvarname=any would also be required here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2012 18:59:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50523#M13803</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2012-02-09T18:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50524#M13804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a question to you&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could I use a&amp;nbsp; dot sql file to sas then to excel? I think you can but not sure&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2014 01:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50524#M13804</guid>
      <dc:creator>thoward</dc:creator>
      <dc:date>2014-03-07T01:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Question on SQL to SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50525#M13805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Should open a new thread for a new question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;however i can assure you that what you describe won't work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Mar 2014 22:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Question-on-SQL-to-SAS/m-p/50525#M13805</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2014-03-07T22:20:14Z</dc:date>
    </item>
  </channel>
</rss>

