BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have a parameter that has several possible entries, i.e., for supervisors, the parameters that can be chosen can be up to 5 in total. To "pull in" the parameters and subsequently use them as part of an IN comparison in a PROC SQL, I have the following code:

To pull in the parameters:

%if &supvcodes0 = %str() %then %do;
%let supvcodesval = "&supervisorycodes";
%end;
%else %do;
%do i = 1 %to %supvcodes0;
%let supvcodesval = &supvcodesval " " "&&supvcodes&i";
%end;
%end;

To compare my data against the parameters in my PROC SQL:

(PERSON_DETAIL.SUPERVISOR_CATEGORY IN (&supvcodesval))

Is this valid code and logic? The reason I ask is that it appears my code, as shown in a PROC REPORT, only hsows records for my first parameter value and not for other values in the same parameter. If there is a better way of doing what I'm attempting, would someone please respond?

Thanks in advance to any who reply....looking forward to your suggestions.
2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
These previous forum responses may be useful to you:
http://support.sas.com/forums/thread.jspa?messageID=1532׼
http://support.sas.com/forums/thread.jspa?messageID=3088ఐ

Generally when you are dealing with a test for a null macro variable the test is coded as:

%if &macvar =; (macro variable has a NULL value which means that, in your case, no value was sent by the client application to the server)
or
%if &macvar ne ; (macro variable has SOME value you don't yet know what)
or
%if %upcase(&macvar) eq WOMBAT %then %do; (when you compare a macro variable to a text string, you don't need quotes).

Have you coded and tested in PROC REPORT, what a working where statement would look like:
where somevar in ("val1", "val2", "val3"); ???

cynthia
deleted_user
Not applicable
Thank you for your timely response, Cynthia! I was quite close on my code, but I think your suggested links will put me onth tohe correct path. I appreciate you being so helpful, and I also appreciate your knowledge!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1398 views
  • 0 likes
  • 2 in conversation