BookmarkSubscribeRSS Feed
schering
Calcite | Level 5
Hi,

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.
6 REPLIES 6
Cynthia_sas
SAS Super FREQ
Hi:
Check out the first program at this web site: [pre]
http://support.sas.com/rnd/itech/doc9/dev_guide/stprocess/input.html [/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";
[/pre]
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.
cynthia
schering
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.
Cynthia_sas
SAS Super FREQ
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
[/pre]
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:

WHERE CUST_CNTRY="&COUNTRY";

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.))";
[/pre]

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?
cynthia
schering
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.
Cynthia_sas
SAS Super FREQ
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]http://www2.sas.com/proceedings/sugi24/Coders/p097-24.pdf
http://www2.sas.com/proceedings/sugi30/002-30.pdf
http://www.bassettconsulting.com/lazy_way.pdfhttp://www.ats.ucla.edu/STAT/sas/library/nesug00/bt3001...
[/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.
cynthia
Vince_SAS
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.

Vince
SAS R&D

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 1662 views
  • 0 likes
  • 3 in conversation