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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register 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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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