Not sure if you tried to include the delimiter in countw function as below
data have;
length string $100.;
string='WORK.DSN1 WORK.DSN2 WORK.DSN3 WORK.DSN4';
c=countw(string,' ');
run;
Not sure if you tried to include the delimiter in countw function as below
data have;
length string $100.;
string='WORK.DSN1 WORK.DSN2 WORK.DSN3 WORK.DSN4';
c=countw(string,' ');
run;
You need to give the COUNTW() function the optional third argument that specifies what charater(s) to consider the delimiter between words.
%put %sysfunc(countw(a.b c.d,%str( )));
use COUNTW function with ' ' as second parameter
In the same step as you create the macro list just add:
select count(*) from SASHELP.VTABLES where LIBNAME="WORK" and memname like "DSN%";
In fact, you could use the data returned from the metadata to directly work with, taking out a layer of abstraction:
E.g.:
data _null_;
set sashelp.vtable (where=(libname="WORK" and substr(memname,1,3)="DSN"));
call execute('%do_somthing(indata='||strip(name)||';');
run;
This would generate a % call for each dataset fulfilling the where clause, in your example, for example:
%do_something(indata=dsn1);
%do_something(indata=dsn2);
%do_something(indata=dsn3);
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.