BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ClayZhai
Calcite | Level 5

hi, I want to create a string of dataset (table) names in TAQMSEC library and separate names by a space. Here since the name format is TAQMSEC.CTM_XXXXXXXX, I want to create a string which looks like:  "TAQMSEC.CTM_20150101 TAQMSEC.CTM_20150102 TAQMSEC.CTM_20150103...". Can someone help me?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

If the datasets already exist then query the system metadata to generate the list.

proc sql noprint;
  select catx('.',libname,nliteral(memname))
    into :memlist separated by ' '
  from dictionary.member
  where libname='TAQMSEC'
    and memtype in ('DATA','VIEW')
  ;
%let nds=&sqlobs;
quit;
%put Found &nds members in TAQMSEC libref : &memlist ;

You might want to also filter on MEMNAME if there are other datasets in that library you don't want to include in your list.

View solution in original post

5 REPLIES 5
sbxkoenk
SAS Super FREQ

Hello,

 

Is this what you want?

data _NULL_;
LENGTH d $ 1100;
 /* "TAQMSEC.CTM_20150101 TAQMSEC.CTM_20150102 TAQMSEC.CTM_20150103...". Can someone help me? */
 d="";
 do i=0 to 30;
  a='01JAN2015'd; 
  b=put(a,yymmddn8.); 
  c=INTNX('DAY',a,i);
  put c= yymmddn8.;
  d=strip(d) !! ' ' !! 'TAQMSEC.CTM_' !! strip(put(c,yymmddn8.));
  put d=;
 end;
 call symputx('myd',strip(d));
run;
%PUT &=myd;

Koen

 

Tom
Super User Tom
Super User

If the datasets already exist then query the system metadata to generate the list.

proc sql noprint;
  select catx('.',libname,nliteral(memname))
    into :memlist separated by ' '
  from dictionary.member
  where libname='TAQMSEC'
    and memtype in ('DATA','VIEW')
  ;
%let nds=&sqlobs;
quit;
%put Found &nds members in TAQMSEC libref : &memlist ;

You might want to also filter on MEMNAME if there are other datasets in that library you don't want to include in your list.

ClayZhai
Calcite | Level 5

Thank you a lot. That is exactly what I want. BTW, in line 4, I guess it should be dictionary.members ('s' is missing). 

Tom
Super User Tom
Super User

SAS uses singular for the SASHELP views and plural for the DICTIONARY psuedo tables. Makes it hard to remember whether or not to add the S.

2226  proc sql;
2227  describe view sashelp.vmember;
NOTE: SQL view SASHELP.VMEMBER is defined as:

        select *
          from DICTIONARY.MEMBERS;
Reeza
Super User
You're aware that you can wild card or use shortcut notation for listing data sets? Ie if you want all the 201501 data sets you could do:

set TAQSEC.CTM_201501: ;

or

set TAQSEC.CTM_20150101-TAQSEC.CTM_20150131;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 867 views
  • 3 likes
  • 4 in conversation