Hello,
I'd like to build a SAS macro programme to generates these SQL instructions on a single line.
Thanks for your help.
DELETE from LIB_ONE.TEMP_TABLE WHERE DAR='$DAR' AND VLD_ENR =1 AND SOURCE ='OP_Z' AND LET_OPE IN ('LEN','SELL') AND TIC_ENT IN ('107','102') AND ISIN IN ('BE00ZZZ', 'BE00YYYYYYY', 'BE001192XXX');
@foxrol94 wrote:
Hello,
I'd like to build a SAS macro programme to generates these SQL instructions on a single line.
Thanks for your help.DELETE from LIB_ONE.TEMP_TABLE WHERE DAR='$DAR' AND VLD_ENR =1 AND SOURCE ='OP_Z' AND LET_OPE IN ('LEN','SELL') AND TIC_ENT IN ('107','102') AND ISIN IN ('BE00ZZZ', 'BE00YYYYYYY', 'BE001192XXX');
I suspect there is more to your actual problem.
But to generate that STATEMENT (lines don't have any importance to either the macro processor or the SQL language) you could just define the macro like this:
%macro mymacro;
DELETE from LIB_ONE.TEMP_TABLE WHERE DAR='$DAR' AND VLD_ENR =1 AND SOURCE ='OP_Z' AND LET_OPE IN ('LEN','SELL') AND TIC_ENT IN ('107','102') AND ISIN IN ('BE00ZZZ', 'BE00YYYYYYY', 'BE001192XXX');
%mend;
Then you could call the macro where ever you want the statement inserted.
proc sql;
%mymacro
quit;
You might want to leave the semicolon out of the body of the macro and instead add it in the program that executes the macro.
@foxrol94 wrote:
I'd like to build a SAS macro programme to generates these SQL instructions on a single line.
Macros create dynamic code, that can change as needed without a human typing new code. What part of this code needs a macro?
Why does the code have to be on a single line?
@foxrol94 wrote:
Hello,
I'd like to build a SAS macro programme to generates these SQL instructions on a single line.
Thanks for your help.DELETE from LIB_ONE.TEMP_TABLE WHERE DAR='$DAR' AND VLD_ENR =1 AND SOURCE ='OP_Z' AND LET_OPE IN ('LEN','SELL') AND TIC_ENT IN ('107','102') AND ISIN IN ('BE00ZZZ', 'BE00YYYYYYY', 'BE001192XXX');
I suspect there is more to your actual problem.
But to generate that STATEMENT (lines don't have any importance to either the macro processor or the SQL language) you could just define the macro like this:
%macro mymacro;
DELETE from LIB_ONE.TEMP_TABLE WHERE DAR='$DAR' AND VLD_ENR =1 AND SOURCE ='OP_Z' AND LET_OPE IN ('LEN','SELL') AND TIC_ENT IN ('107','102') AND ISIN IN ('BE00ZZZ', 'BE00YYYYYYY', 'BE001192XXX');
%mend;
Then you could call the macro where ever you want the statement inserted.
proc sql;
%mymacro
quit;
You might want to leave the semicolon out of the body of the macro and instead add it in the program that executes the macro.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.