BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rodrichiez
Quartz | Level 8

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

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;
Thanks,
Suryakiran

View solution in original post

2 REPLIES 2
Reeza
Super User

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;

 




SuryaKiran
Meteorite | Level 14

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;
Thanks,
Suryakiran

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

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
  • 3064 views
  • 1 like
  • 3 in conversation