<?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: Have PROC SQL within a Data Step?? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41537#M8508</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is possible to use PROC SQL within a DATA step.&amp;nbsp; Take a look at my South Central SAS User's Group paper from last year:&amp;nbsp; &lt;A href="http://www.scsug.org/SCSUGProceedings/2011/poling1/SQL%20Function.pdf"&gt;http://www.scsug.org/SCSUGProceedings/2011/poling1/SQL%20Function.pdf&lt;/A&gt;.&amp;nbsp; While the code presented in the paper only executes a SELECT statement, I think that you could modify the code to execute a CREATE TABLE statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Jan 2012 23:47:32 GMT</pubDate>
    <dc:creator>polingjw</dc:creator>
    <dc:date>2012-01-30T23:47:32Z</dc:date>
    <item>
      <title>Have PROC SQL within a Data Step??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41533#M8504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey guys...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to have multiple PROC SQL statements to be run based on the value of a variable in a dataset.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g. If the value of the 'FLAG' is 1 then i want to run &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL A&lt;/P&gt;&lt;P&gt;create table example &lt;/P&gt;&lt;P&gt;sel * from example1 where key = FLAG &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;, if it is 2, then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SQL B&lt;/P&gt;&lt;P&gt;create table example &lt;/P&gt;&lt;P&gt;sel * from example1 where key = FLAG &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was planning to have PROC SQL within a data step, is it possible?? else what could be the best possible approach to this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 21:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41533#M8504</guid>
      <dc:creator>DrZenith</dc:creator>
      <dc:date>2012-01-30T21:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Have PROC SQL within a Data Step??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41534#M8505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know Macro? is this helpful?&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input flag;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;13&lt;/P&gt;&lt;P&gt;16&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;15&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;select distinct flag into :flags separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let flags=&amp;amp;flags;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;%do i=1 %to %sysfunc(countw(&amp;amp;flags));&lt;/P&gt;&lt;P&gt;%let flag=%scan(&amp;amp;flags,&amp;amp;i);&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; create table want&amp;amp;flag as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select * from sashelp.class&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where age=&amp;amp;flag;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="background-color: white; color: black; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;EM&gt;Linlin&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by:Linlin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 21:26:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41534#M8505</guid>
      <dc:creator>Linlin</dc:creator>
      <dc:date>2012-01-30T21:26:31Z</dc:date>
    </item>
    <item>
      <title>Have PROC SQL within a Data Step??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41535#M8506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To propose "the best" approach is kind of hard as you don't really tell us what you have and what you want (have this data / need this output).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you eventually only looking for a way to split up a table based on some condition?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data outds0 outds1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set example;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if flag=0 then output outds0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else if flag=1 then output outds1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 22:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41535#M8506</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-01-30T22:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Have PROC SQL within a Data Step??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41536#M8507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And another option could be using CALL EXECUTE...&lt;/P&gt;&lt;P&gt;Linus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 22:41:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41536#M8507</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2012-01-30T22:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: Have PROC SQL within a Data Step??</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41537#M8508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is possible to use PROC SQL within a DATA step.&amp;nbsp; Take a look at my South Central SAS User's Group paper from last year:&amp;nbsp; &lt;A href="http://www.scsug.org/SCSUGProceedings/2011/poling1/SQL%20Function.pdf"&gt;http://www.scsug.org/SCSUGProceedings/2011/poling1/SQL%20Function.pdf&lt;/A&gt;.&amp;nbsp; While the code presented in the paper only executes a SELECT statement, I think that you could modify the code to execute a CREATE TABLE statement.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Jan 2012 23:47:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Have-PROC-SQL-within-a-Data-Step/m-p/41537#M8508</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2012-01-30T23:47:32Z</dc:date>
    </item>
  </channel>
</rss>

