BookmarkSubscribeRSS Feed
VD
Calcite | Level 5 VD
Calcite | Level 5

I have a prompt in a stored process which returns an integer value. The prompt allows users to select from a dynamic list. Selecting the prompt is optional. I want to check whether the prompt was selected or not. The selected value doesn't matter - I only want to check if the prompt was selected or not. Is there a way of doing it programatically?

I tried in these two ways by check if the prompt returned a missing value but that didn't work:

/*First*/

%if %eval(&Prompt1 ne .) %then  %let Var1=1;

%else  %let Var1=0;

/*Second*/

%if %sysfunc(missing(&Prompt1))=0 %then  %let Var1=1;

%else  %let Var1=0;

Any suggestions?

Thanks.

4 REPLIES 4
LinusH
Tourmaline | Level 20

The obvious (?) way to go: %put your prompt value when it's not selected.

%eval is not needed when doing comparisons, use it with calculations.

Data never sleeps
VD
Calcite | Level 5 VD
Calcite | Level 5

Thank you, Linus.

I ended up using %length to check if the parameter returned any value or not. It worked.

BrunoSilva
Quartz | Level 8

There's many ways to do it.

Here is a good paper that cover that subject:

IS THIS MACRO PARAMETER BLANK?

http://support.sas.com/resources/papers/proceedings09/022-2009.pdf

Best regards

VD
Calcite | Level 5 VD
Calcite | Level 5

Thanks.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 1275 views
  • 3 likes
  • 3 in conversation