BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I load values into a Parameter for a stored process. The values come from a sql table. one of the values that shows up is NO Department with a value of "NO Department". This apparently does not mean null. I had the parameters working before I converted them over to a store process. If the user did not enter or choose anything from the drop down for the dept, I have a case statement that that seemed to work...
WHERE mascrs.MscSession = "&Semester" AND CASE WHEN "&Dept" Not IS MISSING THEN mascrs.MscDept = "&Dept" ELSE mascrs.MscDept NOT IS MISSING END

However when I make this into a stored process and change the &DEPT parameter so that is lists the name of the dept and the values I have the "No Department" option and instead of getting everyone for all deptments, I get nothing.

Can you help me see a better way to do this? Thanks
3 REPLIES 3
deleted_user
Not applicable
It doesn't make sense to me that an SQL table can have "NO Department" as a value when the table doesn't. That is, unless you have created a format for the column value and add a format for a missing value which translates to "NO Department".

You need to present the UNformatted values to the user for selection since it is these that will be used to select against the data table.

Kind regards

David
deleted_user
Not applicable
I'm not sure how the values get put in myself, I tried unchecking the box apply formating when the Parameter Values are loaded. But I get the same thing.
When I Load Parameter Values in EG Filter and query. It only loads the values.(DeptNUM)
For example...(the first line below is a blank)

18
10
03
97
05
04
08
etc.....
When I do a Create Stored Process and it takes all my code and puts it into a stored process. I then go into the Stored Process Parameters option and Here it shows me 2 columns... Display as... and Resolves to.... When I first open it up both columns are the same. I do a load Values and this time choose DeptName for the Display as column and DEPTNUM for Resolves to
I then get the following
NO DEPARTMENT NO DEPARTMENT
ACADEMIC SUPPORT SERVICES 18
ACCOUNTING 10
ADM SUPR & FIELD SERV 03
AEROSPACE STUDIES 97
ARABIC 05
ART 04
BIOLOGY 08

I can not blank out "NO Department" in the Resolves to column ...it requires something. What I want to happen is if the parameter is not selected ... is blank then give me all of them. That is how it works before I put it into a Stored proc.
Can you tell me how these parameters get set when loading values within a stored process?
Cynthia_sas
SAS Super FREQ
Hi, Cheri:
Here's the deal. When EG builds that parameter list, it allows you to have a 'blank' -- inside EG -- as a possible parameter choice.

However, when EG goes to create a stored process for you and builds the parameter value choices, it does look like you have a user-defined format in place, because otherwise, you would see just the number in both "Display As" and "Resolves To". EG is either putting NO DEPARTMENT into the stored process parameter choice values based on your user defined format -- or is doing it because it does not allow a "blank" character as a choice -- which I can understand. Passing a quoted string or a blank requires that the character be "protected" and protecting a quote or a space for transmission involves some advanced macro programming that is not easily understandable.

But, to deal with the fact that EG put "NO DEPARTMENT" (perhaps based on your user-defined format), you can CHANGE the stored process code for your test. Something like this:
[pre]
%macro testdnum;
%if &DeptNUM = NO DEPARTMENT %then %do;
proc print data=deptdata;
title "No Where clause -- get all departments";
run;
%end;
%else %if &DeptNUM ne NO DEPARTMENT %then %do;
proc print data=deptdata;
where deptnum = &DeptNum;
/* OR where deptnum = "&DeptNUM"; if the deptnum is character */
title "With Where clause -- get only department &deptnum";
run;
%end;
%mend testdnum;
[/pre]

Of course, EG will have put a LOT more code into the stored process. So before you take this approach, you might actually want to contact Tech Support for more help. Changing the code generated by EG can be tricky, because to use Macro conditional logic (%IF), you need to have a macro program (what's defined by the %MACRO and %MEND).

You must already have some logic in place in the EG project for what happened when they picked a space. There are other ways to deal with this than the method I suggest. However, I think that your best bet for a correct answer -- given your data and your parameters and the amount of code you want to conditionally execute -- is to contact Tech Support for help.

To contact Tech Support, go to: http://support.sas.com and on the left hand side, look for the link called "Submit a Problem".

cynthia

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!

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
  • 3 replies
  • 852 views
  • 0 likes
  • 2 in conversation