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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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