BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Solly7
Pyrite | Level 9

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;
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

5 REPLIES 5
andreas_lds
Jade | Level 19

Have a look at the second data step, the input statement needs either infile or datalines statement to process data.

Kurt_Bremser
Super User

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.

ballardw
Super User

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.

yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 5020 views
  • 4 likes
  • 5 in conversation