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?
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;
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.
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):
Perhaps you are not a UNIX user.
I'm very new to UNIX
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;
I need help with this. Will this work in UNIX?
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
Run SAS interactively and use the WINDOW or %WINDOW command to prompt users.
How is the SAS program going to read from STDIN when you have pushed the program into the background by adding & to command line?
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.