Desktop productivity for business analysts and programmers

Macro variable resolution error

Occasional Contributor
Posts: 10

Macro variable resolution error


I am adapting a popular benchmark program that was written for base SAS in Windows to run in Enterprise Guide.  The program does PROC PRINTTO at the top so that it can read the log file at the end and parse out running times.  It was written to place the log file on the C: drive, but now EG is running this in a server environment, so I attempted to change the path from the C: drive to the &SASWORKLOCATION. value.  It didn't work.  Here is the error message:

37         %*let path=c:\temp\;

38         %let path=&SASWORKLOCATION.;


40         options fullstimer;


42         proc printto log="&path.pmbm.txt" new;

NOTE: Line generated by the macro variable "PATH".

42         ""/SASHome/saswork0/Lev1saswork/SAS_work4424000057DF_plccasam1sgn01/SAS_workC6E2000057DF_plccasam1sgn01/"pmbm.txt




ERROR 22-322: Syntax error, expecting one of the following: ;, FILE, LABEL, LOG, NAME, NEW, PRINT, UNIT. 

ERROR 76-322: Syntax error, statement will be ignored.

43         run;

Can anyone please tell me what I did wrong?  And how to correct this so that the file gets written to the SASWORKLOCATION?  I don't want to modify anything else about the benchmark program (such as the choice of PROC PRINTTO) if I don't have to.


Trusted Advisor
Posts: 1,051

Re: Macro variable resolution error

You didn't do anything wrong. Try running this code:


%put &path.;

You'll see that SAS puts double quotes around the path name; you'll need to remove them to use the macro variable.

Super User
Super User
Posts: 6,318

Re: Macro variable resolution error

Your macro variable SASWORKLOCATION already had double quotes around it.


proc printto log=%sysfunc(quote(&sasworklocation.pmbm.txt))  new ;

Or just ask SAS where the work location is:

proc printto log =%sysfunc(quote(%sysfunc(pathname(work))/pmbm.txt)) new ;

Occasional Contributor
Posts: 10

Re: Macro variable resolution error


Thank you to Tom and TomKari for the helpful responses.  The surrounding quotes in the SASWORKLOCATION value were the problem.  The SASWORKLOCATION variable doesn't seem to exist in base SAS 9.3.  I found it by doing %put _ALL_ in EG 6.1, and I didn't realize that the quotes I saw in the log were actually part of the macro variable value.

Tom --


doesn't work, because the quotes are still in the &sasworklocation. value.


would work, but then you have to add in the "/" character, which seems OS specific; it works in UNIX, but would it also work in Windows?

I posted this issue on SAS-L and someone suggested using:

%let path=%sysfunc(dequote(&SASWORKLOCATION.));

That solved the problem.

Super User
Super User
Posts: 6,318

Re: Macro variable resolution error

/ should work in Windows. SAS should handle converting to the appropriate value for your OS.

6    data _null_;

7      infile "%sysfunc(pathname(work))/&sysscp..log" ;

8      input;

9      put _infile_;

10   run;

NOTE: The infile "C:\SAS Temporary Files\_TD5256/WIN.log" is:

      Filename=C:\SAS Temporary Files\_TD5256\WIN.log,

      RECFM=V,LRECL=32767,File Size (bytes)=468,

      Last Modified=07Jan2015:19:50:20,

      Create Time=07Jan2015:19:50:19

Ask a Question
Discussion stats
  • 4 replies
  • 3 in conversation