Hello,
I am stucked on how to setup a stored process to allow an Excell user to pick from the list. Thank you.
%stpbegin;
/* End EG generated code (do not edit this line) */
******************************************************************************************;
LIBNAME E '/sasdata';
DATA RPTO;
SET E.data;
IF MGMTLVL > ' ' ;
KEEP NAME MGR DBFN DBLN DBE;
PROC SORT; BY MGR ;
DATA ALLTEMPS;
LENGTH CLASS $20;
LENGTH UNTYPE $20;
SET E.data;
IF CODE='R' THEN DELETE;
KEEP NAME MGR CLASS ADDRES1 ADDRE2;
PROC SORT; BY MGR;
DATA MALL;
MERGE RPTO ALLTEMPS; BY MGRNO;
IF CLASS= ' ' || LEGNAME =' ' THEN DELETE;
PROC SORT; BY EMPNO;
%MACRO REPORTS;
%global status;
%IF &status = "B" %THEN %DO;
DATA AMALL; SET MALL;
IF CODE='B' THEN CLASS='B';
PROC SORT; BY NAME;
PROC PRINT, ID NAME;
VAR MGR CLASS ADDRES1 ADDRES2 DBFN DBLN DBE;
TITLE3 "B LIST";
%END;
%ELSE %IF &status = "C" %THEN %DO;
DATA NBTEMPS; SET MALL;
IF CODE='C' THEN CLASS='C';
PROC SORT; BY NAME;
PROC PRINT, ID NAME;
VAR MGR CLASS ADDRES1 ADDRES2 DBFN DBLN DBE;
TITLE3 "C LIST";
%END;
%ELSE %IF &status = "D" %THEN %DO;
DATA BARGTEMPS; SET MALL;
IF CODE='D' THEN CLASS='D';
PROC SORT; BY NAME;
PROC PRINT, ID NAME;
VAR MGR CLASS ADDRES1 ADDRES2 DBFN DBLN DBE;
TITLE3 "D LIST";
%END;
%MEND reports;
RUN;
%STPEND;
Thank you for the repsone and yes I am using the SAS add-in for Microsoft. The old program was working fine until I added the merge data step.
Hi:
Your code does not make sense. You have a MACRO definition inside the MERGE step, which is not typically how you define a Macro program. And, since you are defining the Macro program %REPORTS, I would expect you to have an invocation of %REPORTS someplace in your stored process. But I don't see that. The basic way to use Macro processing is to start with a working program and then Macro-tize the program and make a macro definition.
Here's an older paper that outlines the process: http://www2.sas.com/proceedings/forum2008/024-2008.pdf --this was before some of the newer capabilities of the prompting framework, but the basic process is still the same. Look at the example on page 7, which shows the macro definition appearing first and then the Macro program is invoked inside the %stpbegin/%stpend.
cynthia
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.