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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

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
  • 4 replies
  • 1161 views
  • 3 likes
  • 5 in conversation