Hi,
How could I create a table from a list of value enter in a prompt? The type of prompt is a multi line text where the user enter a list of more than 800 account numbers.
By now I've done this:
%LET Accounts = &NR_Accounts;
PROC SQL;
CREATE TABLE WORK.Accounts (Acct num);
INSERT INTO WORK.Accounts
SELECT *
FROM &Accounts;
Below might work for you. Note: This will capture only the values that were selected in prompt not all that exist for the prompt.
This should run in the program where prompt is linked.
%let Accounts=1 2 3 4 5 6 7;
%macro prompt_list();
data test;
format pmt_val $3.;
%do i=1 %to %sysfunc(countw("&Accounts."));
Pmt_val=%scan(%bquote(&Accounts.),&i,%str( ));
output;
%end;
run;
%mend;
%prompt_list;
1. Figure out what your code would look like without macro variables
2. Then replace the parts that are needed with the macro variables.
If you're having trouble please post your working, tested code and the macro variable you've created and we can likely help from there. I suspect that code you've posted does not meet #1, but I'll wait for your response.
@rodrichiez wrote:
Hi,
How could I create a table from a list of value enter in a prompt? The type of prompt is a multi line text where the user enter a list of more than 800 account numbers.
By now I've done this:
%LET Accounts = &NR_Accounts;
PROC SQL;
CREATE TABLE WORK.Accounts (Acct num);
INSERT INTO WORK.Accounts
SELECT *
FROM &Accounts;
Below might work for you. Note: This will capture only the values that were selected in prompt not all that exist for the prompt.
This should run in the program where prompt is linked.
%let Accounts=1 2 3 4 5 6 7;
%macro prompt_list();
data test;
format pmt_val $3.;
%do i=1 %to %sysfunc(countw("&Accounts."));
Pmt_val=%scan(%bquote(&Accounts.),&i,%str( ));
output;
%end;
run;
%mend;
%prompt_list;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.