BookmarkSubscribeRSS Feed
Ronein
Onyx | Level 15

Hello

LEts say I run proc sql query (I must run it because it is many to many  merge that is not working well in data step).

Please note that in this example I didnt perform merge and just want to select speicifc columns by criteria.

Let's say that I want to check which columns exist with name "Offer" in the source data set, and then select them in my query.

What is the way to do it?

I want to select CustID and all columns have  subs tring  "offer" and I wan tto do it via proc sql please

   Data have;
   Input CustID  Offer_Tomato Offer_Banana Milk_offer newspapaer_offer offer_water Firstname $ Year_birth;
   cards;
   111 10 30 20 40 50 Jow 1990
   222 15 25 10 40 18 Yulia 1987
   ;
   Run;
1 REPLY 1
LinusH
Tourmaline | Level 20

This will get you started. Use the macro variable in your query.

   proc sql;
   select name into: offer_col separated by ','
	   from dictionary.columns
	   where libname = 'WORK' 
		and upcase(memname) = 'HAVE' 
		and upcase(name) contains 'OFFER';
   quit;

   %put &offer_col;
Data never sleeps

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1 reply
  • 165 views
  • 3 likes
  • 2 in conversation