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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 933 views
  • 0 likes
  • 2 in conversation