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
SAS Super FREQ
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!

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

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