SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Parsing column names from dataset

Reply
Occasional Contributor
Posts: 8

Parsing column names from dataset

I have dataset (table) that has over 300 column names, I would like to parse out all the column names which are of type=numeric and contain a specific string in name (like "app"). And then all those column names that meet the conditions I would put into a macro variable.

(%let vars = [list of those column names]).

How would should I do that? 

Super User
Posts: 9,914

Re: Parsing column names from dataset

Retrieve the names from dictionary.columns and use the SQL into: clause to populate the macro variable.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,427

Re: Parsing column names from dataset

Why exactly?  I am sure if you provided a bit more information on the process surrounding this request, a far better solution could be found than selecting x number from a large list of variables, and then creating macro code, which you will than have to create even more macro code to work with etc.  Its just exponetiating the code you need to write.

Ask a Question
Discussion stats
  • 2 replies
  • 100 views
  • 1 like
  • 3 in conversation