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 (November 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 17 Nov 2006 05:00:22 -0800
Reply-To:     salsera.77@HOTMAIL.COM
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         salsera.77@HOTMAIL.COM
Organization: http://groups.google.com
Subject:      Re: Using wildcards in IF statement??
Comments: To: sas-l@uga.edu
In-Reply-To:  <200611161527.kAGFL6u3004698@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="iso-8859-15"

Hi again!

I do know the full name, but I want to use the same code for several separate analysis for variables beginning with SEL.

Howards suggestion of arrays worked for me, THANKS!

Mervi

"Howard Schreier <hs AT dc-sug DOT org>" kirjoitti:

> On Thu, 16 Nov 2006 07:15:45 -0800, Frank Poppe <Frank.Poppe@PWCONS.COM> wrote: > > >To me it is not quite clear what the problem is. > > > >Do you mean that you know there is a single variable in your table with > >a NAME starting with 'SEL', but that you do not know what the full name > >is? > >In that case it seems best to do some macro coding prior to the data > >step, to determine the exact name of the variable, putting that in a > >macro variable, and using that in your data step. > > > >Frank Poppe > > Or, this "Cheesy, Sleazy SAS Trick", as M. Davis might call it: > > data demo; > do SEL_unknown_suffix = 10 to 12; output; end; > retain variable2 1; > run; > > data _null_; > set demo; > array SEL_anything (1) SEL : ; > IF SEL_anything(1) = 11 and variable2=1; > put _all_; > run; > > Log shows: > > SEL_unknown_suffix=11 variable2=1 _ERROR_=0 _N_=2 > > As a bonus, dimensioning the array to hold just one variable will cause an > error condition if in fact there are additional variables starting with "SEL". > > > > >salsera.77@hotmail.com schreef: > > > >> I understand that wildcards can only be used for scanning for data > >> values not variable names in IF statements. Using them in variable name > >> like suggested results in error: " Expecting an arithmetic operator." > >> What am I missing here?? > >> > >> Mervi > >> > >> St?phane COLAS kirjoitti: > >> > >> > It works with a Alpha var. because '=:' is like a substr(var,1,?) => A > BEGIN BY > >> > statement, if you want. > >> > > >> > So add quotes : IF SEL: = '11' and variable2=1; > >> > > >> > > >> > St?phane. > >> > > >> > Selon salsera.77@HOTMAIL.COM: > >> > > >> > > Dear SAS users, > >> > > > >> > > I've been trying to figure out a solution to a following problem: > >> > > > >> > > I know my data file contains a variable which begins with characteers > >> > > SEL and I know that I can uniquely identify that variable ie. no other > >> > > variables begin with those characters. I would like to extract > >> > > observations that fill a certaing criterion in that variable and > >> > > simultaniously another criterion in another variable. My first idea was > >> > > to try to use colon wildcard > >> > > > >> > > IF SEL: = 11 and variable2=1; > >> > > > >> > > but this is not possible. > >> > > > >> > > Any ideas how I could come around this problem? > >> > > > >> > > Thanks, > >> > > > >> > > Mervi > >> > >


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