BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
pavank
Quartz | Level 8
%macro create_empty_datasets;
    %do i = 1 %to 100;
        data lib1.ds_&i;
        run;
    %end;
%mend;

%create_empty_datasets;
proc sql;
create table s as
    select libname, memname,memtype
    from dictionary.tables
    where libname = 'LIB1' /* Change to your library name if different */
      and nobs = 0 /* Filters datasets with zero observations */;
quit;

Here I created 100 datasets  so how to identify empty datasets ,datasetnames ,observartions count ,variable names info in a Library

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15

First of all, you didn't create 100 empty data sets each of :

data lib1.ds_&i;
run;

has exactly one observation and zero variables, it's because implicit OUTPUT statement being executed at the end of the data step.

 

To create 100 empty (i.e. zero obs) data set use this:

%macro create_empty_datasets;
    %do i = 1 %to 100;
        data WORK.ds_&i;
          STOP;
        run;
    %end;
%mend;

and you will see that your query works ok.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

1 REPLY 1
yabwon
Onyx | Level 15

First of all, you didn't create 100 empty data sets each of :

data lib1.ds_&i;
run;

has exactly one observation and zero variables, it's because implicit OUTPUT statement being executed at the end of the data step.

 

To create 100 empty (i.e. zero obs) data set use this:

%macro create_empty_datasets;
    %do i = 1 %to 100;
        data WORK.ds_&i;
          STOP;
        run;
    %end;
%mend;

and you will see that your query works ok.

 

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1 reply
  • 595 views
  • 0 likes
  • 2 in conversation