BookmarkSubscribeRSS Feed
RichardP
Quartz | Level 8

Hello, 

 

is it possible to use wildcards in PROC DOCUMENT. For example I would like to perform the same action on all objects within a document directory. 

 


proc document name=test;
 dir \listings;
 obpage \LISTING#1\Report#1\Report#1\Report#1 / after delete;
 obpage \LISTING#1\Report#2\Report#1\Report#1 / after delete;
 obpage \LISTING#1\Report#3\Report#1\Report#1 / after delete;
run;
quit;

replace with 

 


proc document name=test;
 dir \listings;
 obpage \LISTING#1\* / after delete;
run;
quit;

anyone know if this is possible?

 

kind regards,
Richard

5 REPLIES 5
pink_poodle
Barite | Level 11
You can do this with a macro:
%macro cookie;
proc document name=test;
dir \listings;
%do i = 1 %to 3;
obpage \LISTING#1\Report#&i.\Report#1\Report#1 / after delete;
%end;
run;
quit;
%mend;
%cookie;
RichardP
Quartz | Level 8

thanks, yes this would be an acceptable solution. I have not checked yet but is it possible to extract the number of reports for the %do loop value?

pink_poodle
Barite | Level 11
You can supply that parameter into a macro:
* nrep is number of reports;
%cookie(nrep);
...
%do i %to &nrep;
...
%end;
%mend;
%cookie(&nrep);
RichardP
Quartz | Level 8
The thing is I will not always know how many reports are in my catalog. I need this to be dynamic.
pink_poodle
Barite | Level 11

Ok, you can do this using proc sql and Dictionary tables:
(https://documentation.sas.com/?docsetId=lrcon&docsetTarget=p00cato8pe46ein1bjcimkkx6hzd.htm&docsetVe... )

proc sql;
select count(distinct memname) /* not sure it’s memname, view table to verify */
:into &nrep
from dictionary.tables /* not sure it's .tables, check above website to verify */
where libname = “YOUR_CATALOG”
;
quit;

%put &nrep; *check in log that there is something there;

Please make sure that name of library is in capital letters.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2813 views
  • 1 like
  • 2 in conversation