LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 27 May 2009 10:03:11 -0700
Reply-To:     Adam <news@SNOWSTONE.ORG.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Adam <news@SNOWSTONE.ORG.UK>
Subject:      index(), vname() and a macro variable
Comments: To:
Content-Type: text/plain; charset=ISO-8859-1

Hi All,

I'm trying to identify if a variable name is present in a macro variable.

For instance, if a macro variable contains "list of possible variable names" and one of the variables in a dataset is called "possible" then I want to be able to tell.

I had hoped that something like this psuedo-code would work:

%let macro_var = list of possible variable names; data _null_; set indataset; array allvars _numeric_; do i = 1 to dim(allvars); if index("&problem_vars.", vname(allvars{i})) then /* variable name is present in list */ run;

but no matter what I do (including trying out %index, though I'm not sure where the difference is), I can't get the if condition to work (it just evaluates to 0 every time).

Any help much appreciated! Thanks, Adam

Back to: Top of message | Previous page | Main SAS-L page