BookmarkSubscribeRSS Feed
Calcite | Level 5

I have defined the parameter constraints as = pairs. Can anyone tell me how to retrieve the ? Since is defined much more user friendly I would like to use these as part of title/headers of the report. Thanks.
Check out the first program at this web site: [pre] [/pre]

In this program, it shows the use of the "name" piece of the name/value pairs in a title statement:
[pre]title "Product Sales for &MONTH, &YEAR";
In this program, &MONTH and &YEAR are the NAMES of the input parameters (without the & in front) -- that means when you defined them as parameters, whatever you put in the SAS Management Console box for "SAS variable name" now becomes the "NAME" of the parameter (or you could do this in EG as well). For example for me to use &MONTH in my title, I had to define an input parameter called MONTH. The VALUE of the parameter comes from the user who sits at the client application and either types in a value or chooses one of the values you have entered in as constraints for your parameter.
As long as your macro variable reference -inside- the stored process corresponds to the NAME (NOT the prompt) you defined when you registered the SP, then every time the stored process runs, whatever was selected at the client will now be displayed in your title or footnote statement. Remember that since input parameters from the stored process are global macro variables by the time they get to SAS, you must use double quotes around your title statement in order for macro resolution to take place.
Calcite | Level 5
Thanks Cynthia for the response. But I am looking for a way to capture what I think you are referring to as prompt or in EG terminology "Display As" value and not the sas variable name.
Ahhh, I think I understand. Here's how I'm using the terms -- Let's assume an input parameter for Country:[pre]
prompt=Please select a country
SAS Variable Name = COUNTRY
Macro variable usage in program = &COUNTRY
data set var = CUST_CNTRY = 2 char country code
possible constraint values:
Display AS: Resolves to:
United States US
Italy IT
Ireland IR
What you would get if you placed &COUNTRY into a title is 'US' when they select the "Display As" value of 'United States'. And you want to get "United States" in the title???

So, let's assume that your WHERE statement or IF statement has something like this:


I'm figuring you may already have a format in place to translate the 2 character country code to a long country name so someplace before your title, you have to translate the short code to the equivalent of the Display As string: [pre]
title "for country = %sysfunc(putc(&country,$cntry.))";

If your variable is numeric, then you have to use the putn function in your call to %sysfunc. There are other ways to do this with macro processing, but SYSFUNC and a format is one of the easier ways (in my opinion).

Is that what you wanted?
Calcite | Level 5
Yes, this is exactly my question. I am using a look-up table approach which is similar to your format catalog solution. But in either case the look-up table or format catalog should be updated every time when the constraint information changes.

I was really hoping for a solution that the stored process will return this value(s) as a macro variable or some other way. Thanks.
OK...I understand what you mean, now. The "Display As" values are used to build the appropriate prompting interface in whichever client application is running the stored process. Since the client application is not built in the SAS layer, there is no visibility (that I know of) for those "Display As" values in the SAS layer. Formats generally are an efficient way to perform table lookups for label substitution, as described in these papers: [pre]
[/pre] so they're worth giving a try. Especially since you can build a SAS format from a data set or table on the fly using the CNTLIN option of PROC FORMAT.
Rhodochrosite | Level 12
If you are dead-set against formats, you could try this for the parameter definition:
Prompt: Please select a country

SAS Variable Name: COUNTRY

Display as: Resolves to:
United States US:United States
Italy IT:Italy
Ireland EI:Ireland
Instead of using COUNTRY directly in your SAS code, use these variables:
%let  RETURN_VALUE = %scan(&COUNTRY, 1, :);
%let DISPLAY_VALUE = %scan(&COUNTRY, 2, :);
It's not very elegant, but it should work.




Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.


Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6 replies
  • 3 in conversation