BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Onyx | Level 15

Hello

I want to check which data sets with start 'ttt'  are in WORK library and put them in a macro variable with separation by '+'.

In this case the required macro variable will get value ttt1+ttt2+ttt3.

 

What is the way to do it please?

 


Data ttt1;
input ID;
cards
;
2
;
run;

Data ttt2;
input ID;
cards
;
3
;
run;

Data ttt3;
input ID;
cards
;
4
;
run;

Data www;
input City $;
cards
;
Athens
;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

On a new SAS session, you will see this:

 102        Proc sql noprint;
 103           select memname into : VVV separated by '+'
 104           from dictionary.tables
 105           where compress(libname)='WORK' AND  compress(memname) like 'ttt%'
 106           ;
 NOTE: No rows were selected.
 107        run;
 NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
 108        %put &VVV;
 WARNING: Apparent symbolic reference VVV not resolved.

so I take it that your macro variable was already defined from a previous attempt.

Libnames and memnames are always uppercase in the DICTIONARY tables/views.

View solution in original post

4 REPLIES 4
Ronein
Onyx | Level 15

Thanks,

In the result I get also data sets that are not "ttt" , why??

Data ttt1;
input ID;
cards
;
2
;
run;

Data ttt2;
input ID;
cards
;
3
;
run;

Data ttt3;
input ID;
cards
;
4
;
run;

Data www;
input City $;
cards
;
Athens
;
run;


Proc sql noprint;
   select memname into : VVV separated by '+'
   from dictionary.tables 
   where compress(libname)='WORK' AND  compress(memname) like 'ttt%'
   ;
run;
%put &VVV;
Ronein
Onyx | Level 15

Strange,

this query work well 

Proc sql noprint;
   select memname into : VVV separated by '+'
   from dictionary.tables 
   where UPCASE(libname)='WORK' 
			AND  UPCASE(memname) like 'TTT%'
   ;
run;
%put &VVV;
Kurt_Bremser
Super User

On a new SAS session, you will see this:

 102        Proc sql noprint;
 103           select memname into : VVV separated by '+'
 104           from dictionary.tables
 105           where compress(libname)='WORK' AND  compress(memname) like 'ttt%'
 106           ;
 NOTE: No rows were selected.
 107        run;
 NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
 108        %put &VVV;
 WARNING: Apparent symbolic reference VVV not resolved.

so I take it that your macro variable was already defined from a previous attempt.

Libnames and memnames are always uppercase in the DICTIONARY tables/views.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

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
  • 2617 views
  • 4 likes
  • 2 in conversation