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.
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.
It will not work in a macro the same as the CARDS statement does not work in a macro.
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.
What happens if you run the program from a command line?
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.