There are two ways to accomplish what you want.
1) use "Call execute" to make use of macro to work like a function, where you can pass in the value(s) of dataset variable(s) for common processing.
2) pure macro, using %sysfunc and open, fetchops, varnum, getvarN, getvarC, close, etc.
Example of 1)
[pre]
data submitted;
length file_name remote_job $256;
set run_today;
wudatetime = dhms(today,runHour,runMinute,0); *---> wake up datetime;
schedd = put(today,date9.);
scheddt = put(wudatetime,datetime20.);
scheduleddt = cats("'",scheddt,"'dt");
file_name = cats("&BaseRP\&env\dynamic\",program,'.',schedd,'.sas');
file dummy filevar=file_name;
remote_job = catx(',',program,home,scheduleddt,system);
remote_job = '%run_this(' || trim(remote_job) || ');';
put remote_job $;
call execute('%include "' || file_name || '";');
run;
[/pre]
example of 2)
[pre]
%macro getEMAILaddress(user_id,dummy);
%put RP NOTE: entered macro getEMAILaddress(user_id,dummy);
%put . parameter user_id = &user_id ;
%put . parameter dummy = &dummy ;
%local dsid rc varN _&dummy;
%let dsid=%sysfunc(open(misc.users(where=(user_id="&user_id")),i));
%if (&dsid > 0) %then %do;
%let varN = %sysfunc(varnum(&dsid,email_address));
%let rc=%sysfunc(fetchobs(&dsid,1));
%if (&rc = 0) %then %do;
%let _&dummy = %sysfunc(getvarc(&dsid,&varN));
%if %length(&dummy) > 0 %then %let &dummy = &&&&_&dummy ;
%else &&&&_&dummy ;
%end;
%else %put RP ERROR: failed to retrieve an observation from misc.users for user_id=&user_id ;
%let rc=%sysfunc(close(&dsid));
%end;
%else %put RP ERROR: failed to open misc.users ;
%put RP Note: finished getEMAILaddress ;
%mend;
[/pre]
Message was edited by: Chuck