Hi All,
Greetings for the day !!
I have been working on a macro variable called "value" which holds directory paths and some macro names in it.
Example:
Value
sas\\states\test.txt
operations.sas.klist
%OPRMN
data _null_;
i=0;
do until((&var. = " ") or (&value.= " "));
i=i+1;
call symput('scan("&Var.",i,"*")','scan("&value.",i,"*")' );
output;
end;
run;
Here, \\, . these characters in Value variable are causing the issue and throwing the below error.
ERROR: DATA STEP Component Object failure. Aborted during the COMPILATION phase.
ERROR 200-322: The symbol is not recognized and will be ignored.
Can any one please suggest me on this issue.
Looking forward for the solution
Thanks in advance !
What are the contents of macro variables &var and &value?
In this step:
data _null_;
i=0;
do until((&var. = " ") or (&value.= " "));
i=i+1;
call symput('scan("&Var.",i,"*")','scan("&value.",i,"*")' );
output;
end;
run;
they need to resolve to string literals (text in quotes) or variable names to be syntactically correct.
But, since you do not have any incoming data (either from a dataset or an external file), there are no data step variables to use, so variable names make no sense.
In the data you posted in the first part:
Value
sas\\states\test.txt
operations.sas.klist
%OPRMN
there is nothing that resembles a string literal, so it can't be that, either.
What are you trying to achieve?
Hi KurtBremser ,
Thanks for your response.
Var and value are of my 2 macro variables which are having data as below.
Var
--------
a
b
c
Value
----------------
sas\\states\tax\cose\test.txt
operations.sas.klist
%OPRMN
I'm trying to create a, b, c macro variables by using call symput and pass the values respectively from the another variable called "VALUE" (sas\\states\tax\cose\test.txt, operations.sas.klist, %OPRMN) .
For this I have written the previous code which is causing error in reading single '\' and '.'
I used %nrstr, %nrbquote functions also, still no luck.
Use a dataset with name/value pairs, and then it is simple and works:
data lookup;
input name :$10. value :$50.;
datalines;
a sas\\states\tax\cose\test.txt
b operations.sas.klist
c %OPRMN
;
data _null_;
set lookup;
call symputx(name,value,'G');
run;
%put _user_;
partial log:
85 86 %put _user_; GLOBAL A sas\\states\tax\cose\test.txt GLOBAL B operations.sas.klist GLOBAL C %OPRMN
Many thanks for the solution.
Could you please let me know what was wrong in my previous code, why the \, . were not getting read by SAS.
I was doing this by using macro variables, but getting error. Can't we do this with macro variables..?
Doing it from macro variables is possible, but you get WARNINGs for data that looks like macro triggers:
%let var=a*b*c;
%let value=sas\\states\tax\cose\test.txt*operations.sas.klist*%OPRMN;
data _null_;
do i = 1 to countw("&var.","*");
call symput(scan("&var.",i,"*"),scan("&value.",i,"*"));
end;
run;
%put _user_;
Many Thanks KurtBremser and Tom 🙂
This line looks wrong.
call symput('scan("&Var.",i,"*")','scan("&value.",i,"*")' );
You are asking SYMPUT to create a macro variable whose name includes invalid characters like ("&.*,).
Did you want to call the data step function SCAN? If so then don't put it inside of quotes.
call symput(scan("&Var.",i,"*"),scan("&value.",i,"*") );
There is no need to build your own iteration logic. SAS has an iterative DO loop.
do i=1 to countw("&var.","*");
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.