Hi:
Consider this code outside of your specific program needs:
[pre]
options nodate nonumber nocenter;
%let frog = Kermit;
%let show = Sesame Street;
%let fibonacci = 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55;
proc print data=sashelp.class(obs=2);
title 'Single quotes: &frog - &show';
title2 "Double quotes: &frog - &show";
title3 "Fibonacci Series: &fibonacci";
run;
[/pre]
The results of running the above program are:
[pre]
Single quotes: &frog - &show
Double quotes: Kermit - Sesame Street
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55
Obs Name Sex Age Height Weight
1 Alfred M 14 69.0 112.5
2 Alice F 13 56.5 84.0
[/pre]
Note how the quotes are "inside" the SAS program and not in the %LET. I rarely use quotes in my %LET statements.
The trick to knowing when to use quotes with macro variables and macro programs is to start with a working SAS program. for example, these Proc Prints:
[pre]
proc print data=sashelp.class;
title "Obs for Mary";
title2 "working SAS Program";
where name = "Mary";
run;
proc print data=sashelp.class;
title "Obs for Age=15";
where age = 15;
run;
[/pre]
Both work, they are syntactically correct. (I'm not going to show the output from these steps because you can duplicate this code and run the programs yourself to see the results. What you should notice is that in the first PROC PRINT, my where clause is for NAME, which is a character variable -- so I need to have quotes around the string "Mary" for the WHERE statement to be syntactically correct.
In the second PROC PRINT, I am building a WHERE statement for a numeric variable, AGE. So for that statement to be syntactically correct, I do NOT have quotes around the AGE value in the WHERE statement.
SAS treats all macro variables as character strings unless you use a statement that does an implicit conversion to numeric or do an explicit conversion using %EVAL. But this is an OK thing. In this statement:
[pre]
WHERE age = 15;
[/pre]
there's no difference between the macro facility typing 15 for me or me typing it myself. As long as the 15 is a number, without quotes by the time it gets to the compiler, it will be treated OK.
So now, let's say I have these 2 macro variables:
[pre]
%let want = Mary;
%let age = 15;
[/pre]
and I want to use those macro variables in versions of the above program. Well, I know from my test that the quotes are where they need to be and that the above code works to generate the desired results. So all I have to do is put the Macro variables where I have my hard-coded values in the program. Here's the converted Proc PRINT steps:
[pre]
proc print data=sashelp.class;
title "Obs for &want";
where name = "&want";
run;
proc print data=sashelp.class;
title "Obs for Age=&age";
where age = &age;
run;
[/pre]
I do need to have quotes around the title string text. So we know from the first example that those quotes need to be double quotes because macro variables do not resolve in single quotes.
The "macro-ized" version of the program steps will give the same results as the original program steps.
So, in order to use macro variables correctly and to know when to quote or not, it's easier to figure out, if you start with a working SAS program. I have always found this to be a good introduction to the Macro facility and how to construct programs and use macro variables:
http://www2.sas.com/proceedings/sugi28/056-28.pdf
cynthia