I created a prompt called &CPF where I enter several values, I would like to put all the values entered in a table. Prompt
I've tried a few things but nothing worked.
data TESTE; set original (keep=&TESTE); run;
Would anyone know how to do this?
Thanks in advice
When you have a multi-valued prompt, each value is stored in its own macro variable. In your case, we'll suppose that your prompt is named
TESTE. You want to keep only the variables that the user enters.Suppose we're going to run this on sashelp.cars. We want to keep the variables Make, Model, and Horsepower. Create a test program with a prompt named TESTE that runs the following code:
%put _USER_;This displays all user-defined macro variables. Let's run the program with the prompt and check the log.
You will see the following macro variables:
TESTE1-TEST3holds each invidiual value, andTESTE_COUNTgives you the total count of macro varibles. You can use this to loop through and get each value. Note that if you only have one input, only&TESTEwill be created rather than numbered values. We can create a loop that starts at 2 to account for this.You can resolve all of these macro variables into a space-separated list by creating a macro which returns it when you specify the prompt name.