Call Execute Parameterized Include
From sasCommunity
Call Execute a Parameterized Include Subroutine
Using a Data Set as List of Parameters
TinyUrl: http://tinyurl.com/4rf2a7
Download the CallXinc.zip file containing the ..\pdf\Fehd-list-proc-routine-CallXinc.pdf
Quote:
- Any sufficiently advanced technology is indistinguishable from magic.
- Arthur Clarke
- http://en.wikipedia.org/wiki/Clarke's_three_laws
Description: list processing routine which calls a subroutine using values of character columns as values of macro variable assignment statements. Subroutine called references global macro variables
Purpose: list processing
Demonstration of concept:
%Let Parm1 = value1; %Let Parm2 = value2; %Include FileRef(SubRoutine);
CallXinc reads each row of parameter data set, allocates global macro variables for each character variable, and calls -- %Includes -- the subroutine.
Contents |
[edit] CallXinc
* routine name: CallXinc.sas;
* description : Call Execute parameterized Include program;
* purpose : list processing of routine or subroutine;
* note : This is a Derivative Work of CallExecInclude;
* parameters : option source2;
* input : CxData;
* CxInclude;
* process : make mvar of each variable;
* call named Include(s);
* output : from subroutines;
* usage ;
%*Let CxData = sashelp.class;
%*Let CxInclude = SiteIncl(PutGlobal);
%*Include SiteIncl(CallXinc);
* Notes : RJF2 4/23/2008 made routine from Call Execute Suite;
DATA _Null_;
if 0 then set &CxData.;
attrib _Stmnt length = $132
_Name length = $ 32;
array Mvar(*) _character_;
retain Testing %eval(0 or %sysfunc(getoption(Source2)) eq SOURCE2);
do until(EndoFile);
set &CxData. end = EndoFile;
* make statement: *let Mvar = value;
do I = 1 to dim(Mvar) -2;
call vname(Mvar(I) ,_Name);
_Stmnt = catx(' ','%let',_Name,'='
,Mvar(I) ,';');
link ExecStmnt;
end;
_Stmnt = "%Include &CxInclude.;";
link ExecStmnt;
end;
* housecleaning: SymDelete macro vars;
do I = 1 to dim(Mvar) -2;
call vname(Mvar(I) ,_Name);
_Stmnt = catx(' ','%symdel',_Name,';');
link ExecStmnt;
end;
stop;
return; ExecStmnt:
if Testing then putlog _Stmnt=;
call execute(cats('%nrstr(',_Stmnt,')'));
return;
run;
run;
%Put Note2: CallXinc of &CxData. &CxInclude. ending;
[edit] Usage Demonstration
[edit] autoexec
*filename SiteIncl '<directory-specification>'; *filename SiteIncl 'C:\SAS-site\includes';
[edit] CallXinc-Test
* name: CallXinc-Test; %Let CxData = sashelp.class; %Let CxInclude = Project(PutGlobal); %Include SiteIncl(CallXInc); %Let CxData = sashelp.class(where = (Sex = 'F')); %Let CxInclude = Project(PutGlobal); %Include SiteIncl(CallXInc);
[edit] PutGlobal
* name: PutGlobal; %Put _global_;
- This routine is in the SmryEachVar v2 data review suite:
- and is included in the .zip of both
- Reading Job Logs
- Reading Rtrace Logs
This is R&D for the book: A SAS(R) Companion: http://www.sascommunity.org/wiki/Journeymens_Tools
--macro maven == the radical programmer 11:11, 12 September 2008 (EDT)
BibTeX entry for this page:
@inproceedings{sas-wiki.callxinc,
booktitle={SAS Community Wiki},
year = 2008,
author ={Ronald J. Fehd},
title ={Call Execute a Parameterized Include},
note ={url for this article},
url ={http://www.sascommunity.org/wiki/Call_Execute_Parameterized_Include}}
- This page was last modified 22:02:53, 2008-09-12.
- This page has been accessed 199 times as of 2008-Oct-01.
- This page was last modified 20:51:07, 2008-10-01.
- This page has been accessed 350 times as of 2008-Oct-28.
- This page was last modified 15:49:39, 2008-11-14.
- This page has been accessed 793 times as of 2008-Nov-14.
