Date: Fri, 4 Nov 2011 07:08:52 -0400
Reply-To: Nat Wooding <nathani@VERIZON.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <nathani@VERIZON.NET>
Subject: Re: Passing a variable value as condition into a where clause
In-Reply-To: <201111040841.pA41IEWL030408@waikiki.cc.uga.edu>
Content-Type: text/plain; charset="UTF-8"
Fernando
Jim gave an approach and here is another which evaluates the values in target in a loop.
Nat Wooding
data Source;
numcli=1;
Typcli="1111";
Target= "1111,21";
output;
numcli=2;
Typcli="1211";
Target= "1111,21";
output;
run;
Data Wanted;
set source;
drop _I_ ;
Do _i_ = 1 to ( countc( target , ',' ) +1 );
if Typcli = Scan( target , _i_ , ',' ) then output;
end;
run;
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Fernando Tenorio
Sent: Friday, November 04, 2011 4:42 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Passing a variable value as condition into a where clause
Hello everybody,
I’m trying to use the value of a variable in a where clause as the example
below:
data Source;
numcli=1;
Typcli="1111";
Target="Typcli in ('1111','21')";
output;
numcli=2;
Typcli="1211";
Target="Typcli in ('1111','21')";
output;
run;
data target_out;
set source;
where target;
run;
And I would like to have as output:
Numcli TypeCli
1 1111
But the where clause is not working as desired. I would like to know how
could I pass the value of the variable "target" into the where clause.
Many thanks,
Fernando Tenorio.