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);
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.