Hi,
Below is my requirement
Column_A Column_B
ABC 21
ABC 23
XYZ 31
XYZ 33
We are creating a macro variable for ABC value but when someone will pass BAAC value instead of ABC then also it should read value of ABC
Can anyone help me on this
Thanks
Harsh
I've no idea what you mean, but here is something that meets the current "requirements". Enjoy.
data have;
input Column_A $ Column_B;
datalines;
ABC 21
ABC 23
XYZ 31
XYZ 33
;
run;
%macro doit(in=,out=,param=);
data &out.;
set &in.;
where Column_A eq 'ABC'
%if %nrbquote(¶m.) ne %then %do;
or upcase(Column_A) eq upcase("¶m.")
%end;
;
run;
%mend doit;
%doit(in=have,out=want,param=blabla);
- Cheers -
Please be precise.
why should BAAC return the value of ABC?
Is it because the string BAAC contains all the characters of ABC?
what about XYZ? should xXYzZ also return values of XYZ? what about "X Y Z"?
- Cheers -
Actually, i cant provide data so i have provided example
But actually if somebody will pass different parameters apart from ABC then also ABC parameter should pass
Remaining value should be kept as it is
I've no idea what you mean, but here is something that meets the current "requirements". Enjoy.
data have;
input Column_A $ Column_B;
datalines;
ABC 21
ABC 23
XYZ 31
XYZ 33
;
run;
%macro doit(in=,out=,param=);
data &out.;
set &in.;
where Column_A eq 'ABC'
%if %nrbquote(¶m.) ne %then %do;
or upcase(Column_A) eq upcase("¶m.")
%end;
;
run;
%mend doit;
%doit(in=have,out=want,param=blabla);
- Cheers -
Thanks, i got answer from your code
@harshpatel wrote:
Actually, i cant provide data so i have provided example
But actually if somebody will pass different parameters apart from ABC then also ABC parameter should pass
Remaining value should be kept as it is
It's fine that you have provided an example. However, the explanation needs a lot more detail. Step-by-step, please explain what happens, in detail. That's the only way we can help you write code.
I'll let you know as soon as I finish writing my mind-reading app. 🤓
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.