BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
harshpatel
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Oligolas
Barite | Level 11

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(&param.) ne %then %do;
         or upcase(Column_A) eq upcase("&param.")
      %end;
      ;
   run;
%mend doit;
%doit(in=have,out=want,param=blabla);

 

________________________

- Cheers -

View solution in original post

7 REPLIES 7
Oligolas
Barite | Level 11

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 -

harshpatel
Quartz | Level 8

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

Oligolas
Barite | Level 11

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(&param.) ne %then %do;
         or upcase(Column_A) eq upcase("&param.")
      %end;
      ;
   run;
%mend doit;
%doit(in=have,out=want,param=blabla);

 

________________________

- Cheers -

harshpatel
Quartz | Level 8

Thanks, i got answer from your code

 

PaigeMiller
Diamond | Level 26

@harshpatel 

Please mark the correct response as correct!!

--
Paige Miller
PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
ballardw
Super User

I'll let you know as soon as I finish writing my mind-reading app.   🤓

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 757 views
  • 1 like
  • 4 in conversation