BookmarkSubscribeRSS Feed
KyleS83
Calcite | Level 5
suppose I have 5-6 different SAS data sets stored in my C: drive (example c:/SASData)

What would be an effective macro that I could use that would display (using proc print) all of the data sets in that C: folder?


Thanks for the help!
4 REPLIES 4
ArtC
Rhodochrosite | Level 12
here is a possible solution:
[pre]%macro printit(dsn=);
title1 Printing &dsn;
proc print data=&dsn(obs=5);
run;
%mend printit;

%macro getdatalist(lib=);
%local count i;
proc sql noprint;
select distinct memname
into :mem1 - :mem&sysmaxlong
from dictionary.members
where libname=upcase("&lib");
quit;
%let count = &sqlobs;
%do i = 1 %to &count;
%printit(dsn=&lib..&&mem&i);
%end;
%mend getdatalist;
%getdatalist(lib=sasclass)
[/pre]
Ksharp
Super User
Just as Arthur.Carpenter 's code.But I used call execute() which is interface of macro facility with dataset.If you like.
[pre]



libname mylib 'c:\temp';
data _null_;
set sashelp.vtable(where=(libname='MYLIB'));
call execute('proc print data=mylib.'||strip(memname)||';');
call execute('run;');
run;
[/pre]


Ksharp
johnP
Calcite | Level 5
/* first assign your folder to a libname */
libname newLib 'c:/SASData';

/* to just show dataset names in ouput window */
proc sql;
select memname
from
dictionary.members
where libname='newLib'
;
quit;

/* or to put the dataset names into a dataset and then view with proc print */
proc sql;
create table newDataset as
select memname
from
dictionary.members
where libname='newLib'
;
quit;
proc print data=newDataset;
run;
RMP
SAS Employee RMP
SAS Employee
if you are only interested in the characteristics of the datasets and not the physical data then you can use

proc contents data=lib._all_;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 4 replies
  • 1446 views
  • 0 likes
  • 5 in conversation