08-16-2012 01:32 PM
I have some data and proc report code that I want to record a pop-up macro for.
I have a list of 1000 possible numbers that can be entered and when a number is entered such as 00460, the code created pulls the data for that number only. An example of the code is this:
data one; set all13;
if code = '00460';
create table temp as
(select distinct clm from one
where rv_cd in ('589','270','462','012'));
and the code really goes on and on to pull various information in regards to that code 00460.
When I get to the end of the code the final piece is an html output of the report that was derived from all the proc sql, data statements of this code.
What I want is to create a macro that will start with a pop-up window asking the user to enter the code they want to run the report on. So say the pop says please enter code and you enter 00100 and then the code between the macro runs all the way to the output and the user never has to do anything but input that code into the popup window. Therefore there is no need to go in and change anything in regards to the actual data. I am just trying to make this so they don't have to re-enter a new code in the actual code everytime if that is possible.
08-16-2012 02:19 PM
Lets split this task up a little.
First the macro should have an input parameter that accepts the code.
%macro mymac(code= .......); .... %mend mymac;
This is how the code it passed into the macro to control which code to generate the report for. You might have other parameters it needs.
Second the first thing the macro needs to do it verify that the code passed is a valid code so that it can stop and complain rather than run through dozens of steps reporting nothing from the data.
Third you need another program or macro that accepts the user input and then calls the macro that does the real work.
For this you can use %WINDOW and %DISPLAY to paint a form on the screen and accept user input. Google for "SAS %window %display" and you will find lots of papers. Such as: http://www2.sas.com/proceedings/sugi24/Coders/p092-24.pdf