Hello Everyone, I have a macro that I am using to run some PROC SQL code. I am using the macro's input both in creating the output table name and in the SQL's WHERE clause. When I run the macro, I don't put quotes around the input string because that would not work when creating the table name. However, I need the input string to have quotes around it for the WHERE clause. Here is an example of the situation below. I've searched around a bunch for solutions to this and none of them seem to be working. I'm still relatively new to SAS, so I really appreciate anyone's advice on this, or if you have a link to a similar solution that would work. %macro test_example (subject_name);
PROC SQL;
CREATE TABLE WORK.Report_&subject_name. AS
SELECT *
FROM LIB.TABLE_NAME
WHERE FIELD1 = &subject_name. /*Tried this.*/
WHERE FIELD1 = CAT("'", &subject_name., "'") /*Tried this too.*/
WHERE FIELD1 = "'"||&subject_name.||"'" /*Tried this as well.*/
;
QUIT;
%mend;
%test_example(Item1); I could just create a second input in the macro, one that has single quotes around the same input string repeated, but I feel like there must be a better, simpler solution than that. I am using SAS Enterprise Guide 7.15. Thank you, Ben
... View more