In general, When we need to handle the macro variable, we need to use quote function to mask these special characters. But For your situation, You only pass the value of macro variable to Data Step Compiler, if you use quote function ,you will get error. Let me give an example. %let sex=%nrbquote('F'); data female; set sashelp.class; where sex=&sex; run; This code will produce ERROR. Because you have masked single quote . when it arrived Data Step Compiler, Compiler only take the value as F ,not 'F'. Why? because you masked this single quote.But If you use the code below, you will get right result. Why? because you didn't mask this single quote ,Compiler can recognize this single quote, Compiler think the value you passed is 'F'. %let sex='F'; data female; set sashelp.class; where sex=&sex; run; If you really want to use quote function around the value of macro variable ,then use %unquote to unmask single quote to let Complier know them correctly. %let sex=%nrbquote('F'); data female; set sashelp.class; where sex=%unquote(&sex); run; Ksharp
... View more