Your SAS programs, embedded in web apps and elsewhere

To decide if a prompt has been selected or not

Reply
Frequent Contributor
Frequent Contributor
Posts: 94

To decide if a prompt has been selected or not

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.

Super User
Posts: 5,424

Re: To decide if a prompt has been selected or not

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
Frequent Contributor
Frequent Contributor
Posts: 94

Re: To decide if a prompt has been selected or not

Thank you, Linus.

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

Contributor
Posts: 50

Re: To decide if a prompt has been selected or not

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

Frequent Contributor
Frequent Contributor
Posts: 94

Re: To decide if a prompt has been selected or not

Posted in reply to BrunoSilva

Thanks.

Ask a Question
Discussion stats
  • 4 replies
  • 454 views
  • 3 likes
  • 3 in conversation