Hi, i am trying to create an sample banking payment suggestion decision engine but i get an error ERROR: No DATALINES or INFILE statement when i run second part of my code where i need to prompt the user to enter recipient details(i.e cellphone number/card number/account number) as well as the amount they wish to send. see below code.
Your assistane would be greatly appreciated
data payment_options; input method $ cost maximum_amount; datalines; RPP 7 3000 Instant_Payment 7 3000 EFT_On_Us_PAYU 1 1000000 EFT_Off_Us_PAYU 1 1000000 EFT_Pay_to_Cell_PAYU 1 1000000 EFT_On_Us_Bundled 0 1000000 EFT_Off_Us_Bundled 0 1000000 EFT_Pay_to_Cell_Bundled 0 1000000 eWallet 2 3000 RTC 45 450000 ; run; /* Prompt the user for recipient information and amount */ data _null_; put 'Enter recipient information (cellphone, card, account): '; input recipient_info $; put 'Enter amount to send: '; input amount; run; /* Use an IF-ELSE statement to suggest the best payment method */ data suggest_payment; set payment_options; if recipient_info = 'cellphone' and amount <= 3000 then output; else if recipient_info = 'card' and amount <= 1000000 then output; else if recipient_info = 'account' and amount <= 1000000 then output; else put 'Invalid recipient information or amount'; run; proc print data=suggest_payment; run;
This
/* Prompt the user for recipient information and amount */
data _null_;
put 'Enter recipient information (cellphone, card, account): ';
input recipient_info $;
put 'Enter amount to send: ';
input amount;
run;
cannot work. PUT writes to the log or an external file (if assigned with FILE), and INPUT reads from files (INFILE) or DATALINES.
User prompts can be defined in Enterprise Guide and used in EG projects or stored processes.
Have a look at the second data step, the input statement needs either infile or datalines statement to process data.
This
/* Prompt the user for recipient information and amount */
data _null_;
put 'Enter recipient information (cellphone, card, account): ';
input recipient_info $;
put 'Enter amount to send: ';
input amount;
run;
cannot work. PUT writes to the log or an external file (if assigned with FILE), and INPUT reads from files (INFILE) or DATALINES.
User prompts can be defined in Enterprise Guide and used in EG projects or stored processes.
Depending on the SAS environment the method for "prompting for user" changes.
If you are using a Display Manager environment you want to research the WINDOW and %WINDOW statements, which allows showing a prompt and reading data from a response. Otherwise describe the environment you are working in.
If you aren't going to save the responses in a data set then perhaps the %Window is appropriate to create macro variable values that could be used in your third data step directly.
For SAS EG there are "prompts", SAS even did a video about it:
https://video.sas.com/detail/video/6295499870001/create-and-use-prompts-in-queries-and-tasks
Bart
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: