Help using Base SAS procedures

stdin stdout

Reply
New Contributor
Posts: 3

stdin stdout

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?

Esteemed Advisor
Esteemed Advisor
Posts: 6,977

Re: stdin stdout

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;

New Contributor
Posts: 3

Re: stdin stdout

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.

Esteemed Advisor
Esteemed Advisor
Posts: 6,977

Re: stdin stdout

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

Respected Advisor
Posts: 3,773

Re: stdin stdout

Perhaps you are not a UNIX user.

Filerefs Assigned by SAS in UNIX Environments

New Contributor
Posts: 3

Re: stdin stdout

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?

Super User
Super User
Posts: 6,133

Re: stdin stdout

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

Super User
Super User
Posts: 6,133

Re: stdin stdout

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

Super User
Super User
Posts: 6,133

Re: stdin stdout

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

Esteemed Advisor
Posts: 6,268

Re: stdin stdout

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 9 replies
  • 579 views
  • 0 likes
  • 5 in conversation