I need to get the index of a macro value in another macro string. findw seemed like it would work for this but it does not work with sysfunc. I made an example below.
the code below sets varfind = 0 and varfinddata =3; the warning message is:
WARNING: In a call to the FINDW function or routine, the modifier "'" not valid.
quoting the space such as
varfind = %sysfunc(findw("&testin","&count",%str(" "), %nrstr(%str('E')) ));
does not seem to help. what is failing when trying to use sysfunc?
%let testin =v vsd count f;
%let count =count;
%macro test();
var="&testin";
varfind = %sysfunc(findw(&testin,"&count",' ', 'E'));
varfinddata=findw("&testin","&count", ' ', 'E');
%mend test;
data a;
%test
run;
%let testin = v vsd count f;
%let count =count;
%let varfind = 0;
%let varfind = %sysfunc(findw(&testin, &count, %str(' ') , e));
%put &varfind;
This works for me.
@weg wrote:
I need to get the index of a macro value in another macro string. findw seemed like it would work for this but it does not work with sysfunc. I made an example below.
the code below sets varfind = 0 and varfinddata =3; the warning message is:
WARNING: In a call to the FINDW function or routine, the modifier "'" not valid.quoting the space such as
varfind = %sysfunc(findw("&testin","&count",%str(" "), %nrstr(%str('E')) ));does not seem to help. what is failing when trying to use sysfunc?
%let testin =v vsd count f; %let count =count; %macro test(); var="&testin"; varfind = %sysfunc(findw(&testin,"&count",' ', 'E')); varfinddata=findw("&testin","&count", ' ', 'E'); %mend test; data a; %test run;
%let testin = v vsd count f;
%let count =count;
%let varfind = 0;
%let varfind = %sysfunc(findw(&testin, &count, %str(' ') , e));
%put &varfind;
This works for me.
@weg wrote:
I need to get the index of a macro value in another macro string. findw seemed like it would work for this but it does not work with sysfunc. I made an example below.
the code below sets varfind = 0 and varfinddata =3; the warning message is:
WARNING: In a call to the FINDW function or routine, the modifier "'" not valid.quoting the space such as
varfind = %sysfunc(findw("&testin","&count",%str(" "), %nrstr(%str('E')) ));does not seem to help. what is failing when trying to use sysfunc?
%let testin =v vsd count f; %let count =count; %macro test(); var="&testin"; varfind = %sysfunc(findw(&testin,"&count",' ', 'E')); varfinddata=findw("&testin","&count", ' ', 'E'); %mend test; data a; %test run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.