BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am using 2 parameters. One is for the low range the other is for the high range. Both are drop downs with a list of values. I want the user to be able to only put in the low value if they only want 1 value and not a range. In that case I need the 2nd parameter to = the first parmeter.

Any idea on how to do this?? I have tried multiple things and nothing seems to work. Like making the default of parmeter2 parameter1. Probably just not doing something quite right.

example.... parm1 ...selects 0012
parm 2 selects 0014 then the result is everthing from 0012 to 0014

example2 parm1 selects 0012
parm2 nothing selected then only want 0012 results.
2 REPLIES 2
deleted_user
Not applicable
Hi, Cheri,

Here is a suggestion (please keep in mind the pseudo code in my reply is not the exact code you will need):

In a data step:

If parm2 eq
then parm2 = parm1;
run;

The data step must have the run; command as its last line.

I'm assuming you will be using a Proc SQL later, so you would then, in Proc Sql, have something like the following:

Proc Sql;
CREATE TABLE YourTable AS SELECT field1, field2
FROM YourOtherTable AS CallItWhatever
WHERE YourOtherTable.field1 BETWEEN "&parm1" and "&parm2";
Quit;

Don't forget....you might need to include logic in your data step that checks to make sure the second parm is equal to or larger than the first parm, but not smaller than the first parm.

Hope this helps. Also, in these forums, there is a lady from SAS, by the name of Cynthia, who has been a tremendous help to me. If you can catch her attention, she is wonderful on replying and on helping!
Olivier
Pyrite | Level 9
Sticking to the EG logic, you can define your second parameter (let's say it's called MAX and the first one MIN) with &MIN as the default value.
In your condition, specify :
yourVariable
BETWEEN
&min AND %UNQUOTE(&max)

By default, EG prevents using more than one step of macro-variable (parameters) resolutions. So the &max --> &min --> value is forbidden by default : that's why default values for parameters are enclosed in %NRSTR() function calls at the beginning of the code.
Using the %UNQUOTE function will cancel the effect of the %NRSTR protection and allow your definition of &max being equal to &min.

And any user value overriding the &min value for MAX will also work out fine (at least on the example I've used to test).

Regards,
Olivier

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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