%macro InsertTable(pSourceTable=, pLoadMethod=, pDataTransferID=);
proc sql;
insert into <TableName>
(
Column1,
Column2,
Column3,
Column4
)
select
Column1,
Column2,
case
when &pLoadMethod ='D' then Column3
when &pLoadMethod ='F' then &pDataTransferID.
end as Column3,
case
when &pLoadMethod ='D' then Column4
when &pLoadMethod ='F' then 'I'
end as Column4
from &pSourceTable.;
quit;
%mend InsertTable;
%InsertTable(pSourceTable=SourceTable, pLoadMethod='D', pDataTransferID=1); I think you are looking for the code that I have written above. I see problem in case statement. After Case keyword there should be variable name. I do not find any macro variable as LoadMethod in the given code. Suggest you to try the code with actual variable first. Once code run fine then replace the variables with macro variable. case &LoadMethod. when 'D' then Column3 when 'F' then &pDataTransferID. end as Column3,
... View more