Here is the code for format issue at Netezza,
proc sql noprint;
connect to netezza (user=mxxxx pwd=xxxx SERVER=bsnet01z database=PDWAPPRP connection=global autocommit=yes);
execute ( create temporary table STDY
( SUB_NUM char(13) )) by netezza;
execute ( create temporary table ANTIB
( NDC char(11) )) by netezza;
insert into dw.STDY (bulkload=YES bl_options='logdir "."')
select SUB_NUM from pulllist /* list of SUB_NUM, no "in" or "other"*/
where flag='study';
insert into dw.ANTIB (bulkload=YES bl_options='logdir "."')
select NDC from sparc_ndc /* list of CLM_NDC, no "Y" or "other";*/
where ndc ~='';
execute( Create temporary table PHARM_STDY_DW as
Select distinct
D.MEM_NUM , D.SUB_NUM , D.MEM_BIRTH_DT, D.MEM_GENDER,
A.PRESCRIPT_NUM ,
A.PRESCRIB_NPI ,
A.NUM_REFILLS ,
A.incurred_dt_key ,
B.CLM_NDC ,
C.MDDB_TC_CLASS_CD ,
A.METRIC_QUANTITY ,
A.DAYS_SUPPLY ,
A.PRESCRIB_DEA_NUM
FROM
V_PHARM_SERVICE A,
V_PHACLM_DRUG B,
V_MDDB_DRUG C,
V_CLAIM_MEMBER_PROFILE D,
V_INCURRED_DATE E,
STDY,
ANTIB
WHERE
D.SUB_NUM=STDY.SUB_NUM AND
B.CLM_NDC=ANTIB.NDC AND
A.curr_clm_ind ='Y' and
A.MEM_PROF_KEY = D.MEM_PROF_KEY and
A.PHACLM_DRUG_KEY = B.PHACLM_DRUG_KEY and
A.MDDB_DRUG_KEY = C.MDDB_DRUG_key and
A.INCURRED_DT_KEY = E.INCURRED_DT_KEY and
E.INCURRED_DT_DAY between &cov_start and &cov_end
) by netezza;
/* bulkunload table from netezza to ADM as SAS dataset */
create table SPARC.PHARM_STDY_DW_08 as
select * from DW.PHARM_STDY_DW
(bulkunload=YES BL_DELIMITER='|' bl_options='logdir "."');
disconnect from netezza;
quit;