The field names come in that way from external source system. Rather than process twice, the rename statement is used in the first step. This macro runs fine until I add the %macro and %mend lines. Get an error on the infile statement /* Macro 2.2 GEN_BCListings */ %macro GEN_BCListings(bcin=); LIBNAME CCIMP 'D:\CCIMP\'; *%let bcin='D:/CCIMP/skus-2015-06-08.csv'; data BC_ITEMS (rename= ('Product SKU'n = BC_SKU 'Stock Level'n = BC_QTY) drop= 'Product UPC/EAN'n); infile "&bcin" dlm = ',' MISSOVER DSD lrecl=32767 firstobs=2 ; informat "Product SKU"N $30. ; informat "Product UPC/EAN"N $1. ; informat "Stock Level"N best32. ; format "Product SKU"N $30. ; format "Product UPC/EAN"N $1. ; format "Stock Level"N comma12.0 ; input "Product SKU"N $ "Product UPC/EAN"N $ "Stock Level"N ; run; proc sort data=bc_items out=bc_item_sort; by bc_sku; run; data CCIMP.BCListings (keep= BC_QTY BC_SKU) ; format po $char10. subsku 8.; set bc_item_sort; p=index(BC_SKU,'.'); po = substr(BC_SKU,1,p-1); subsku =input(substr(BC_SKU,p+1,length(BC_SKU)-p),8.); period = find(bc_sku,'.'); if po = ret_po and period NE 0 then do; /*eliminates IC 1344 etc from consideration*/ if subsku LT ret_subsku and ret_period GT 0 then do; /*handles IC 1344 followed by 1344.01*/ BC_SKU =trim(left(bc_sku))||'0'; subsku = subsku *10; end; if subsku LT ret_subsku and ret_period GT 0 then do; /*second pass for 100*/ BC_SKU =trim(left(bc_sku))||'0'; subsku = subsku *10; end; if subsku LT ret_subsku and ret_period GT 0 then do; /*second pass for 1000*/ BC_SKU =trim(left(bc_sku))||'0'; subsku = subsku *10; end; end; ret_period = period; ret_po = po; ret_subsku =subsku; retain ret_po ret_subsku ret_period; run; proc summary data=CCIMP.BCListings ; format _freq_ comma8.0 qbe_qoht comma8.0 retail_value dollar14.2; var BC_QTY; output out=bclisting_stat sum=bc_qty n=bc_sku; run; data bclisting_stat2 (keep=runmacro runfile records total_units rundate runtime); format runmacro $char20. runfile $char60. ; set bclisting_stat (rename= (_FREQ_ = records bc_qty = Total_Units)); rundate = "&sysdate"; runtime = "&systime"; runfile = &bcin; runmacro = 'GEN_BCListings'; run; proc append base=CCIMP.load_stat data=bclisting_stat2; run; %mend GEN_BCListings;
... View more