简体   繁体   中英

Passing a value from Netezza back to SAS using a macro variable

we're using SAS 7.13 HF1 (7.100.3.5419) (64-bit)

I'm currently looking at a post that shows how to pass a value from SAS to a database that you're connecting in to. Here is the example below. You can see they take the Macro variable StartDate and pass it into Teradata to be used in the query.

%let StartDate = 2016/01/01;

proc sql;
   connect to teradata 
    (BULKLOAD=YES MODE=TERADATA user=&user. Password=&passwd.);

   CREATE TABLE WorkTest.test AS
   select * from connection to teradata
   ( 
        SELECT 
            TOP 10 *      
        FROM SomeCalendarData
        WHERE SomeDate = %bquote('&StartDate.');
   ); 
quit;

I want to go the other way.

How can I read a value from a similar query, only my DB is Netezza, and somehow pass it to a macro variable in SAS?

Thanks!

You would use the

SELECT <expression> INTO :<macro_var>'

statement. This is available in the PROC SQL query but not in the pass-through code, so it would look something like

proc sql;
   connect to teradata 
    (BULKLOAD=YES MODE=TERADATA user=&user. Password=&passwd.);

   select somedate into :my_macro_var from connection to teradata
   ( 
        SELECT somedate      
        FROM SomeCalendarData
        WHERE id = 101;
   ); 
quit;

See the docs here: http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#n1tupenuhmu1j0n19d3curl9igt4.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM