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

Updating stored process prompts in EG 7.1 

See attached.

Prompt SBU is a static list and includes the option of "ALL"

Market  is dynamic drop down lists built from an external file and is dependent on SBU.

File building MARKET does not contain option for ALL.

 

I want to be able to only pick SBU while leaving MARKET blank and then interpret this as MARKET = ALL in the program.

I'm able to do this by allowing blank as a choice. Then when parm passes to program it shows on the log as MARKET=; and resolves to MARKET=''.

 

I've tried various methods to "read" what is in MARKET parm...is it blank? null? Missing? but nothing works...there must be a way to determine what is contained in MARKET in order to re-set it to ALL...

 

any thoughts are appreciated.


Capture.JPG
1 ACCEPTED SOLUTION

Accepted Solutions
BHull
Obsidian | Level 7

Thank you!

test shows parm is null...

I think I solved it by doing this.

%MACRO TEST;

%if &market > '' %then %let market = &market;

%else %let market=ALL;

%MEND;

 

View solution in original post

4 REPLIES 4
Quentin
Super User
In your stored process, if you code %put >>&market<<; what do you see in the log? If it shows >><< then the macro variable is null. If you see quotation marks between the angle brackets, then that is the value of the macro variable (would be odd).
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
BHull
Obsidian | Level 7

Thank you!

test shows parm is null...

I think I solved it by doing this.

%MACRO TEST;

%if &market > '' %then %let market = &market;

%else %let market=ALL;

%MEND;

 

Quentin
Super User

Testing for null macro vars is suprisingly tricky.

&market > ''  will actually compare the value of &market to the value of two quote marks.  The macro language does not use quotation marks in the same way as the data step language.  In the macro language, quot marks are part of the value, just like any other text.

 

Chung & King have a nice paper on how to test for blank parameters. 

http://changchung.com/download/022-2009.pdf

 

Their approach would suggest you use something like:

%MACRO TEST;

%if %sysevalf(%superq(market)=,boolean) %then %let market = ALL;

%MEND;

 

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
BHull
Obsidian | Level 7
Thank you for your reply....
I found this paper and actually tried to use this solution...was not successful.
I'm sure it was my limited understanding of macro language...but I was able to sort it out using reverse logic...
%MACRO TESTBLANK;
%if &market > '' %then %let market = &market;
%else %let market=ALL;
%MEND;

May not be elegant but it works...
Thanks again...

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1053 views
  • 0 likes
  • 2 in conversation