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

Hi, I am learing the %input statement by running an example on the SAS's official  site: http://support.sas.com/kb/1/887.html

%macro test;

  %put enter the data:;

  %input getdata;

  %put The data you entered is: &getdata; run;

%mend test;

%test

However, this only resulted in an error: ERROR: Requested function is not supported.

I did follow the recommendation that: 'The workaround is to run the code within the SAS Program Editor rather than the SAS Enhanced Editor.'. But even so, the error still exists.

Do you know what's wrong with the %input statement?

Thanks a lot.

1 ACCEPTED SOLUTION

Accepted Solutions
SASJedi
SAS Super FREQ

You can enter the input data later by:
1.  Submit the macro definition code:

%macro test;                                                                                                                          

   %put enter the data:;                                                                                                              

    %input getdata;                                                                                                                   

    %put The data you entered is: &getdata;                                                                                           

run;                                                                                                                                  

%mend test; 

2. Submit the macro call:
%test

In the log you will see:

enter the data:

3. Type your data into the program editor window all by itself, and submit
abc123

In the log you will see the message:
The data you entered is abc123

It's kind of like getting user input with %WINDOW and %DISPLAY, without the windows... 🙂

Not sure how practical it is, though.

Check out my Jedi SAS Tricks for SAS Users

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

It will not work in a macro the same as the CARDS statement does not work in a macro.

art297
Opal | Level 21

It will work if you are using the program editor, rather than the enhanced editor, but I think that the input has to be part of the submitted program code.  e.g., the following will work:

%macro test;                                                                                                                           

   %put enter the data:;                                                                                                               

    %input getdata;                                                                                                                    

    %put The data you entered is: &getdata;                                                                                            

run;                                                                                                                                   

%mend test;                                                                                                                            

                                                                                                                                       

%test                                                                                                                                  

xxxyyyzzz                                                                                                                              

However, I can't think of where that might be useful.

data_null__
Jade | Level 19

What happens if you run the program from a command line?

SASJedi
SAS Super FREQ

You can enter the input data later by:
1.  Submit the macro definition code:

%macro test;                                                                                                                          

   %put enter the data:;                                                                                                              

    %input getdata;                                                                                                                   

    %put The data you entered is: &getdata;                                                                                           

run;                                                                                                                                  

%mend test; 

2. Submit the macro call:
%test

In the log you will see:

enter the data:

3. Type your data into the program editor window all by itself, and submit
abc123

In the log you will see the message:
The data you entered is abc123

It's kind of like getting user input with %WINDOW and %DISPLAY, without the windows... 🙂

Not sure how practical it is, though.

Check out my Jedi SAS Tricks for SAS Users

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1590 views
  • 3 likes
  • 5 in conversation