12-11-2012 07:05 AM
%macro import(path,name, out, sheet);
proc import datafile ="&path\&name.xls"
out=&out(where= (refid ~= .))
mixed = yes;
Suppose I want call macro with path like "d:\Clin-Dem\HCC\New Folder". How can I mask the colon in the path?
%import(%superq(d:\Clin-Dem\HCC\New Folder),%str(Cheng, Ann-Lii_2009_vol10), dataset4, Template);
12-11-2012 07:22 AM
You are using SUPERQ incorrectly.
I don't think the colon needs to be quoted. You need two dots after &NAME any you may need to %UNQUOTE all that.
12-11-2012 10:26 AM
And perhaps a period after &path
Here's an example that I use with multiple macro variables in an output file name:
%let outpath= D:\Data\WIC\Nutrition Surveillance Rpt\Trend\output\ ;
ods rtf file="&outpath.district_&district._&syear._&eyear..rtf"
12-11-2012 11:17 AM
Like data _null_ said, you don't have to quote the colon.
I suggest the following changes. (I'm sending this from home, so don't have SAS in front of me to test):
1) Use keyword instead of positional parameters. It makes the syntax clearer, and IIRC removes the significance of the comma in your name parameter.
2) If your parameters could contain tokens significant to the macro processor, you would use %superq *inside* the macro, not in the parameter declaration.
3) If a macro variable contains text immediately following that would make the macro variable reference ambiguous, use a dot to mark the end of the macro variable reference. So, like data _null_ said, you need two dots after &name, one to mark the end of the macro variable reference, and one as the filename extension delimiter.
4) Most punctuation and whitespace will mark the end of a macro variable reference, so a following dot is not required. I see some programmers "overuse" the dot to end a macro variable reference, when it's not required. It works, but I personally find this syntax harder to read and a bit "ugly". But that's just me.
Try this and see how it works for you:
out=&out (where=(refid is not missing))
Alternatively, you could use:
as long has your path or name variables aren't too funky, with characters that would confuse the macro processor. Usually %superq() is needed in macro statements such as %if %superq(mvar) ne %str() ..., but while %superq in the above syntax may be over-cautious, it won't hurt.
If the comma in the name parameter confuses the macro processor, try: