BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cosmid
Lapis Lazuli | Level 10

Hi,

 

I have the following code:

%macro test;
  %put Type in a name:;
  %input inName;
  %put The name you entered is &inName;
%mend test;

%test;

When I run this code in Windows:

Nothing happens, the two put statements are printed out in the log window.

 

When I run this code in UNIX:

I get two blank lines but it is waiting for an input. After type something, there will be another blank line and it takes me back to the command line. When I check the log file, the variable inName stores what I have typed in.

 

Is there something wrong with my code or I am approaching it in the wrong direction? I just wanted to ask the user for input.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@cosmid wrote:

Hi Tom, the SAS in Windows, I just click on the SAS 9.4 (English) at the Start Menu and it'll open up SAS Windows. And in UNIX, I just type in sas & to start SAS there and it will load about 4 to 5 separate windows, for log, editor, etc.


So look at the definition of the ICON you are clicking on to see where SAS lives on your computer and try typing that command from a command window.  THen you can see if it will also accept input from the terminal the way it did in Unix.

 

Since you appear to be using DISPLAY MANAGER in both cases you can use the %WINDOW statement to get your user input. Check out the second example in the documentation.  https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0ojc9rtfrzvbdn16kqd2c5mzobq.htm

 

View solution in original post

20 REPLIES 20
sbxkoenk
SAS Super FREQ

Hello,

 

On what OS are you intending to use this code? On Windows or on Unix?

 

No idea why the 

%INPUT Macro Statement

does not seem to work on SAS Windows.

 

But are you sure you want to go there?

There are many other and much better ways to capture user input. 

  • %WINDOW Macro Statement
  • %DISPLAY Statement Macro Statement
  • %INPUT Macro Statement

can still be used but they are old stuff!

 

What SAS are you using: SAS 9.4 Mx or SAS Viya?
Do you have Enterprise Guide or do you have Visual Analytics?

 

Thanks,

Koen

cosmid
Lapis Lazuli | Level 10

Wow, I didn't know there are so many options. I NEED to have this working in UNIX environment. It would be nice to know how it will work in Windows, but not as important. I do have SAS Enterprise Guide but I rarely use it as I am still 'newbie' in this field.

 

Once I have time, I would like to investigate the difference between SAS Windows and SAS Enterprise Guide. At a glance, they seem to work similarly. I only heard that Enterprise Guide is more point and click.

Reeza
Super User

When a %INPUT statement executes as part of an interactive line mode session, the macro processor waits for you to enter a line containing values. In a windowing environment session, the macro processor does NOT wait for you to input values. Instead, it simply reads the next line that is processed in the program and attempts to assign variable values.

 

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n1jspx1ctztpvzn1gpkw12oe3661.htm

 

Looks like you're running in interactive mode in Unix and not in Windows.

 


@cosmid wrote:

Hi,

 

I have the following code:

%macro test;
  %put Type in a name:;
  %input inName;
  %put The name you entered is &inName;
%mend test;

%test;

When I run this code in Windows:

Nothing happens, the two put statements are printed out in the log window.

 

When I run this code in UNIX:

I get two blank lines but it is waiting for an input. After type something, there will be another blank line and it takes me back to the command line. When I check the log file, the variable inName stores what I have typed in.

 

Is there something wrong with my code or I am approaching it in the wrong direction? I just wanted to ask the user for input.

 

Thanks


 

cosmid
Lapis Lazuli | Level 10

Hi Reeza, thank you for pointing that out. I didn't read the document carefully enough.Now I understand why it doesn't work in Windows. Right now I am just trying to figure out what I need to have the code working in UNIX.

Reeza
Super User
I don't think I've ever seen %INPUT used for user input by the way....usually if you need prompts I'd recommend using EG instead.
cosmid
Lapis Lazuli | Level 10

What is EG? Thanks

sbxkoenk
SAS Super FREQ

EG = Enterprise Guide.

Very easy to prompt the user for input in Enterprise Guide.

Koen

cosmid
Lapis Lazuli | Level 10

Hi Koen! Yes, I just googled it and yet you still beat me to it.

cosmid
Lapis Lazuli | Level 10

Ok, SAS Enterprise Guide. But it seems if I have it working in EG it will not work in UNIX since they are kind of different unless I missed something there too? lol

 

Unfortunately, I need the code working for UNIX.

sbxkoenk
SAS Super FREQ

Hello,

Enterprise Guide can be your front-end to a UNIX SAS session.

Have a look how your Enterprise Guide is set up?

Does it connect to a Windows SAS or does it connect to a UNIX SAS?

Koen

cosmid
Lapis Lazuli | Level 10

It's connected to the Windows SAS.

Reeza
Super User
Enterprise Guide is the front end. Is this going to be run by a developer in the back end or are you developing something for an end user to run for SAS where they select specific parameters?

When you say it needs to run on Unix is that SAS running on Unix or end users will be access SAS to run this themselves on Unix?
cosmid
Lapis Lazuli | Level 10

The EG is only available on my Windows. Other users don't have access to it. They need access to this program in UNIX environment since that's where all the data resides. When they run the code. I need to prompt them to ask which section of the code they want to run otherwise everything will be executed and will take a long time for the code to complete. I just need them to enter like a number between 0-5 and it'll work.

Tom
Super User Tom
Super User

How did you start the SAS session on Windows that is running the code?  Did you open a command window and type a command like 

sas myfile

like you would from a Unix prompt?

 

Or did you click on something in Windows graphical user interface?  If so what did you click on? What does it do? How does it actually end up running SAS?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 20 replies
  • 1129 views
  • 9 likes
  • 5 in conversation