Read Selected Members Using a Prefix

Reply
Super Contributor
Posts: 358

Read Selected Members Using a Prefix

Hi all you clever people:

I have created a program that reads selected members from a SAS table using a prefix, such as:

DATA STUFF;

SET infile.af:  ;

which reads all members in "infile" that begin with "AF".

This works fine on our development server - which is running 9.3, but will not run on our production

system, which is running 9.1 - seems this change was made in SAS in 9.2.

I know that there is a way to read the dictionary tables, read the members in the library from there and then

build a list to read, but I would like to do this with a macro so I can select the "prefix" for each set of members

to select and re-use it for different selections in the same program.

Any help would be appreciated.

Valued Guide
Posts: 2,177

Re: Read Selected Members Using a Prefix

proc copy select statement has supported this : handling since before sas v6

Alternatively populate the ds list with code like :

%let parm = sashelp.v:  ;

proc sql noprint ;

select catx('.', libname, memname )

  Into :mem_list separated by ' '

   From dictionary.members

   Where libname = "%upcase(%scan( work.&parm,-2,.))"

     And memname eqT "%upcase(%scan(&parm,-1,:.))"

;

quit ;

%put found &sqlobs things beginning &parm. The list is &mem_list ;

The EQT operator is similar to datastep =: operator.

Look up the online doc for proc sql to see that EQT does what you want.

Message was edited by: Peter Crawford  .. .. ..  really,  proc copy is not enough

Ask a Question
Discussion stats
  • 1 reply
  • 169 views
  • 0 likes
  • 2 in conversation