BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FlorianG
Calcite | Level 5

Good evening,

 

does anyone know how to use the %input statement in a macro in order to read in a value for a macro variable?

I use SAS Enterprise Guide, so the macro is written in the code window. 

 

My first attempts unfortunately didn't work.

I tried something like this:

 

%macro identi; 
%put Type in your name; 
%input name; 
%put Type in your age; 
%input age; 
%put &name is &age years old; 
%mend identi; 

%identi;

When you start the program, there is no possibility for the user to type in the values for the variables. Only the log window opens.

Do I have to program an extra window where the user can type in the variable values or is there something else wrong?

 

Any help would be greatly appreciated.

 

Regards,

FlorianG

1 ACCEPTED SOLUTION

Accepted Solutions
DMoovendhan
Quartz | Level 8

%input  works well in sas PC and in command prompt, but for command prompt sas you can use x command and echo instead of %put to pass on the message to the interface.

 

_prompt_ works well in noth sas pc and in sas EG.

View solution in original post

3 REPLIES 3
ballardw
Super User

For EG you may want to look at PROMPT.

The %input and %window statements were created before much in the GUI. Also, the variables you create this way would exist for the duration of the macro (brief). You would want to add %Global statements to make the varaibles persist after the macro runs. See the documentation on scope of macro variables.

DMoovendhan
Quartz | Level 8

%input  works well in sas PC and in command prompt, but for command prompt sas you can use x command and echo instead of %put to pass on the message to the interface.

 

_prompt_ works well in noth sas pc and in sas EG.

FlorianG
Calcite | Level 5

Thank you very much. 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 2856 views
  • 2 likes
  • 3 in conversation