Learning SAS? Welcome to the exclusive online community for all SAS learners.

how to get the datasets from one library

Reply
Contributor
Posts: 40

how to get the datasets from one library

hi firends

  i have a library  name test;

the test library containts datasets like

x_1_20150128   /* yyyymmdd*/

x_1_20150225

x_1_20150329

x_1_20150420

x_1_20150525  .



here  how to get the  present month and persent year     and not about date.

dates are differents for datasets.


plz help me.

Super User
Posts: 17,760

Re: how to get the datasets from one library

What do you want your output to be?

You can use the today() function to get the current date and then format it as yyyymmdd.

Super User
Posts: 10,472

Re: how to get the datasets from one library

If you want to combine data sets you can use a list such as:

data want;

     set x_1_201504: ;

run;

to get the sets that start with specific characters.

But really, what are you going to do with the data sets once they are identified? The approaches can vary quite a bit.

And there may be additional bits needed such as to any of the desired datasets start with something other than X_1_?

If so do you want them included or just the ones that start with X_1_?

Trusted Advisor
Posts: 1,128

Re: how to get the datasets from one library

the below code will create a macro variable dates with list of datasets names with today() month and year

data have;

x=cats(put(year(today()),4.),put(month(today()),z2.));

call symputx('x',x);

run;

proc sql;

select memname  into:dates separated by ' ' from dictionary.tables where upcase(libname)='WORK' and

compress(memname,,'kd') ne '' and cats(substr(compress(memname,,'kd'),2,4),substr(compress(memname,,'kd'),6,2))="&x";

quit;

Thanks,

Jag

Thanks,
Jag
Ask a Question
Discussion stats
  • 3 replies
  • 316 views
  • 0 likes
  • 4 in conversation