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

I have the following datasets in a list;

		proc sql noprint;
		select   distinct  MEMNAME 
			into    :MEM_LIST separated by " "
				from    DICTIONARY.COLUMNS
					where   LIBNAME="PMODA";
quit;
%put &MEM_LIST;
APR_19 APR_20 AUG_19 DEC_19 FEB_19 FEB_20 JAN_19 JAN_20 JUL_19 JUN_19 MAR_19 MAR_20 MAY_19 NOV_19 OCT_19 SEP_19 YEAR_TO_DATE_19

However, I want to only have datasets which end in _19 in my variable called mem_list.

 

I've tried to use and memname like "19%" in my sql query but this does appear to pick it up.

 

Can anyone provide some suggestions, please?

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @Sean_OConnor  How about using SCAN

 

where   LIBNAME="PMODA" and scan(memname,-1,'_')='19';

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

Hi @Sean_OConnor  How about using SCAN

 

where   LIBNAME="PMODA" and scan(memname,-1,'_')='19';
Sean_OConnor
Obsidian | Level 7
That does the trick nicely!
Sean_OConnor
Obsidian | Level 7
Sorry, a quick further questions. Is there an easy way to include pmoda. before each mename? So when I look at my list it would be like pmoda.apr_19 pmod.aug_19
novinosrin
Tourmaline | Level 20

Well if you are filtering using LIBNAME='PMODA' , you would only have those datasets in that library.

 

Hmm, I am wondering whether you are asking to concatenate the libname with memname? Is this correct?If yes, you may want to do this-   

select distinct catx('.',libname,MEMNAME) as memname

	select   distinct  catx('.',libname,MEMNAME) as memname 
			into    :MEM_LIST separated by " "
				from    DICTIONARY.COLUMNS
					where   LIBNAME="PMODA";
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
  • 5 replies
  • 1567 views
  • 1 like
  • 2 in conversation