Please considering following two statements. 2nd data step returns correct index function result but 1st one failed. Any sugguestion to make index function work with %let statement? Many thanks.
%let num=%sysfunc(index('/abc/cde/dev/data/ods','/data'));
%put #
data _null_;
num=index('/abc/cde/dev/data/ods','/data');
put num=;
run;
L
Try this:
%let num=%index(/abc/cde/dev/data/ods,/data);
%put #
The macro processor generally doesn't use the quotes to deal with strings.
Also there are several MACRO language specific string functions you should use instead of working around the differences when using %sysfunc such as %index, %scan, %substr, %trim and variations such as %Kscan %qkscan,%ksubstr, %ktrim
Try this:
%let num=%index(/abc/cde/dev/data/ods,/data);
%put #
The macro processor generally doesn't use the quotes to deal with strings.
Also there are several MACRO language specific string functions you should use instead of working around the differences when using %sysfunc such as %index, %scan, %substr, %trim and variations such as %Kscan %qkscan,%ksubstr, %ktrim
Thanks for all your reply. It looks like quotes are not necessary in this case. Both statements work the same below.
%let num=%index(/abc/cde/dev/data/ods,/data);
%put #
%let num=%index(/abc/cde/dev/data/ods,/data);
%put #
The quotes are considered part of the strings by the macro processor. So there is no match because of the quotes around /data.
See what happens if you try it this way.
%let num=%sysfunc(index(/abc/cde/dev'/data'/ods','/data'));
Hi Tom, thanks for your answer. It worked out great.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.