If you use explicit pass-through
(direct connection to DB2), you can use the SAS_PUT( ) function
call in your SQL program.
This
example shows the same query from
Implicit Use of the SAS_PUT( ) Function and explicitly uses the SAS_PUT( ) function call.
%let mapconn=user=sasts password=xxxx database=indb;
libname dblib db2 &mapconn;
data dblib.shoes;
set sashelp.shoes;
run;
options sastrace=',,,d' sastraceloc=saslog;
proc sql noerrorstop;
title 'Test SAS_PUT using Explicit Passthru ';
connect to db2 (user=sas3 password=sas31 database=indb);
select * from connection to db2
(select distinct (sas_put("SALES",'DOLLAR12.2')) as "SALES_C" from SHOES);
disconnect from db2;
quit;
The following lines
are written to the SAS log.
1733
1734 proc sql noerrorstop;
1735 title 'Test SAS_PUT using Explicit Passthru ';
1736 connect to db2 (user=db2 password=XXXXXXXXXXXX database=indb);
DB2: AUTOCOMMIT is YES for connection 4 1870 1309265953 ducon 0 SQL
1737 select * from connection to db2
1738 (select distinct (sas_put("SALES",'DOLLAR12.2')) as "SALES_C" from
SHOES);
1871 1309265953 du_prep 0 SQL
DB2_366: Prepared: on connection 4 1872 1309265953 du_prep 0 SQL
select distinct (sas_put("SALES",'DOLLAR12.2')) as "SALES_C" from SHOES 1873
1309265953 du_prep 0
SQL
1874 1309265953 du_prep 0 SQL
DB2: COMMIT performed on connection 4. 1875 1309265953 du_comm 0 SQL
1876 1309265953 du_exec 0 SQL
DB2_367: Executed: on connection 4 1877 1309265953 du_exec 0 SQL
Prepared statement DB2_366 1878 1309265953 du_exec 0 SQL
1879 1309265953 du_exec 0 SQL
1739 disconnect from db2;
1740 quit;
Note: If you explicitly use the
SAS_PUT( ) function in your code, it is recommended that you
use double quotation marks around a column name to avoid any ambiguity
with the keywords. For example, if you did not use double quotation
marks around the column name, DATE, in this example, all date values
would be returned as today's date.
select distinct
cast(sas_put("sales", 'dollar12.2') as char(12)) as "sales_c",
from shoes;