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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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