BookmarkSubscribeRSS Feed
siri2020
Calcite | Level 5

I'm trying to submit this code

data _null_;

file stdout;

infile stdin;

put @5 "input x?:";

input x;

run;

And this is what I get

********/********/********/******>    input x?:

3

ksh: 3:  not found

[11] + Stopped (SIGTTIN)        sas test1.sas &

Can't figure out where I'm going wrong?

9 REPLIES 9
RW9
Diamond | Level 26 RW9
Diamond | Level 26

What is stdout and stdin defined as?  There should be filerefs:

fileref stdin "c:\abcd.txt";

...

Next, why are you tring to put a string ""?  Do you want to read from stdin and write to stdout?  If so:

fileref stdin "c:\abc.txt";

fileref stdout "c:\def.txt";

data _null_;

  file stdout;

  infile stdin;

  input x $;

  put @5 x;

run;

siri2020
Calcite | Level 5

I want this to be an interactive SAS program. That is, ask the user a question, take in the answer and output accordingly. Hence the string.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Base SAS doesn't have any particularly good wasy of getting user input, you could look at prco window, or there is this (haven't used it myself):

http://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p0fy35488gnc66n1sezjg...

data_null__
Jade | Level 19

Perhaps you are not a UNIX user.

Filerefs Assigned by SAS in UNIX Environments

siri2020
Calcite | Level 5

I'm very new to UNIX Smiley Happy

I don't think %window or window will work with SAS in UNIX.

data _null_;

file stdout;

infile stdin;

put @5 "Do you want to print and email the tracker(Y/N)?:";

input ans;

Capture.PNG

Capture1.PNG

I need help with this. Will this work in UNIX?

Tom
Super User Tom
Super User

Works for me. I would separate the writing and the reading as two steps to eliminate any timing issues.

data _null_;

file stdout;

put "Do you want to print and email the tracker(Y/N)?:";

run;

data _null_;

infile stdin;

input ans $ ;

put ans= ;

stop;

run;

Do you want to print and email the tracker(Y/N)?:

y

Tom
Super User Tom
Super User

Run SAS interactively and use the WINDOW or %WINDOW command to prompt users.

Tom
Super User Tom
Super User

How is the SAS program going to read from STDIN when you have pushed the program into the background by adding & to command line?

Kurt_Bremser
Super User

If you already run this from the commandline (batch mode), I'd suggest to handle the input in a shell script (with the read command) and supply the values to the SAS program via environment variables or the -sysparm commandline option (SAS(R) 9.2 Macro Language: Reference).

Base SAS is not really good at being interactive.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 9 replies
  • 3623 views
  • 1 like
  • 5 in conversation