1
votes

The variable department has a value of M&S in the data step

set ttt;        
    DepartmentComp=Compress(DepartmentComp);*For use in making directories;       
    CALL SYMPUT('ggg',trim((division)));
    CALL SYMPUT('fff',trim((Department)))

the log displays SYMBOLGEN: Macro variable FFF resolves to M&S WARNING: Apparent symbolic reference S not resolved.

How can I get rid of the warning as I suspect that it affects the program?

2

2 Answers

1
votes

Use %superq() to mask the '&' and prevent resolution of '&S'. Here's an example for you:

 60         data test;
 61         comp = "%superq(fff)";
 62         putlog "NOTE: comp=%superq(fff)";
 63         run;

 NOTE: comp=M&S
 NOTE: The data set WORK.TEST has 1 observations and 1 variables.
1
votes

If you are using those variables in a subsequent datastep you could use symget to avoid premature attempts at resolution (as follows):

data _null_;
   division='%myDiv';
   department='Food&Drink';
   call symputx('ggg',division);
   call symputx('fff',department);
run;

data someds;
   division=symget('ggg');
   department=symget('fff');
   putlog division= department=;
run;

Points to note:

  • Other than raising an error condition (syscc=4) it's difficult to say if that warning will affect your program (if you create a macro variable of &s it would). In any case, it's always best to avoid warnings if at all possible.
  • You can use symputx instead of symput, which will automatically strip leading / trailing blanks
  • The %superq approach proposed by floydn is a good one for direct use in macro logic.