<?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: Macro Question...Using dataset observation values in Proc SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57440#M12399</link>
    <description>You can use hash objects as lookup table in Data step.&lt;BR /&gt;
&lt;A href="http://support.sas.com" target="_blank"&gt;http://support.sas.com&lt;/A&gt;</description>
    <pubDate>Wed, 29 Oct 2008 19:31:04 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-10-29T19:31:04Z</dc:date>
    <item>
      <title>Macro Question...Using dataset observation values in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57434#M12393</link>
      <description>Greetings. I am relatively new to SAS (but have a good deal of experience in Oracle PL\SQL).&lt;BR /&gt;
Is it possible to, &lt;BR /&gt;
1. Loop through a SAS Dataset&lt;BR /&gt;
2. Assign one of the observation values , say Customer #, to a variable&lt;BR /&gt;
3. Execute a macro (passing that Customer # variable) that performs a PROC SQL against an Oracle/Teradata database table and returns the information to a SAS dataset and/or variable&lt;BR /&gt;
&lt;BR /&gt;
I've done some research on this and it appears that it can be done using the SYMPUT function. But I wanted to confirm with a user group first.&lt;BR /&gt;
I know how to do this using PL/SQL, but nor SAS.&lt;BR /&gt;
&lt;BR /&gt;
Any advice is appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
Troy</description>
      <pubDate>Mon, 27 Oct 2008 19:16:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57434#M12393</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-27T19:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Question...Using dataset observation values in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57435#M12394</link>
      <description>Hi:&lt;BR /&gt;
  My suggestion is to take a look at the SAS Macro Facility, specifically the way that CALL EXECUTE works. The documentation is here &lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000543697.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/59526/HTML/default/a000543697.htm&lt;/A&gt; &lt;BR /&gt;
 &lt;BR /&gt;
and there are 2 relevant examples in the documentation.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 28 Oct 2008 03:43:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57435#M12394</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-10-28T03:43:00Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Question...Using dataset observation values in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57436#M12395</link>
      <description>Also consider the RESOLVE function within the DATA step facility, however I am unclear about your stated interest - is it that you want to invoke PROC SQL for each DATA step pass as you are creating observations?  The phrasing of your post is unclear about how/when you want to perform the stated objective -- that being serially or each/all tasks with each pass of your data?&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 28 Oct 2008 03:49:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57436#M12395</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2008-10-28T03:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Question...Using dataset observation values in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57437#M12396</link>
      <description>If it's about passing a single value as a constant to an SQL statement then consider something like the following (more or less the approach you drafted):&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
  set yourtable;&lt;BR /&gt;
  if &lt;SOME condition=""&gt; then&lt;BR /&gt;
  do;&lt;BR /&gt;
    call symput('MyMacroVar',cats("'",myvar,"'"); /* pass value of myvar to macro variable &amp;amp;MyMacroVar */&lt;BR /&gt;
    stop; /* no further iterations through dataset */&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
 ....&lt;BR /&gt;
 where MyField=&amp;amp;MyMacrovar ....&lt;BR /&gt;
....&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If it's about joining (subselect,...) two tables, one in Oracle and one in SAS then let us know.&lt;BR /&gt;
&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
P.S. Just in case you don't know this one already:&lt;BR /&gt;
options sastrace=',,,d' sastraceloc=saslog;&lt;BR /&gt;
&lt;A href="http://support.sas.com/onlinedoc/913/getDoc/en/acreldb.hlp/a000433982.htm" target="_blank"&gt;http://support.sas.com/onlinedoc/913/getDoc/en/acreldb.hlp/a000433982.htm&lt;/A&gt;

Message was edited by: Patrick&lt;/SOME&gt;</description>
      <pubDate>Tue, 28 Oct 2008 07:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57437#M12396</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-10-28T07:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Question...Using dataset observation values in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57438#M12397</link>
      <description>Scott,&lt;BR /&gt;
I want to perform the lookup for each observation in the dataset;for each pass of the data.&lt;BR /&gt;
&lt;BR /&gt;
So, for example, if I had a dataset with 50 customers, I will perform a PROC SQL query based on one or more of the columns for each of the 50 observation dataset.&lt;BR /&gt;
&lt;BR /&gt;
In PL\SQL, I could achieve this with code resembling the following.&lt;BR /&gt;
&lt;BR /&gt;
Cursor C_Main is&lt;BR /&gt;
Select CustomerID, ProductID, PurchaseDate&lt;BR /&gt;
from    SomeTable;&lt;BR /&gt;
&lt;BR /&gt;
For C1_Rec in C_Main -- This loops through each record in the returned dataset&lt;BR /&gt;
Loop&lt;BR /&gt;
     1. Perform Lookup information from other dataset(s).&lt;BR /&gt;
     2. Assign variables, etc based upon business logic&lt;BR /&gt;
     3. Update another table with variables values assigned in step 2.&lt;BR /&gt;
End loop;&lt;BR /&gt;
&lt;BR /&gt;
I'll work on the SAS equivalent this week and post my example.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help.&lt;BR /&gt;
Troy</description>
      <pubDate>Wed, 29 Oct 2008 17:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57438#M12397</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-29T17:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Question...Using dataset observation values in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57439#M12398</link>
      <description>If you can describe more in detail what end result you want, maybe we could give suggestions for other approaches that haven't thought of. Some sample input and input data could help.&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Wed, 29 Oct 2008 18:16:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57439#M12398</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-10-29T18:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Question...Using dataset observation values in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57440#M12399</link>
      <description>You can use hash objects as lookup table in Data step.&lt;BR /&gt;
&lt;A href="http://support.sas.com" target="_blank"&gt;http://support.sas.com&lt;/A&gt;</description>
      <pubDate>Wed, 29 Oct 2008 19:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Question-Using-dataset-observation-values-in-Proc-SQL/m-p/57440#M12399</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-29T19:31:04Z</dc:date>
    </item>
  </channel>
</rss>

