Date: Wed, 27 May 2009 07:50:37 -0400
Reply-To: "SUBSCRIBE SAS-L Joe H. Smith" <peesari.mahesh@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "SUBSCRIBE SAS-L Joe H. Smith" <peesari.mahesh@GMAIL.COM>
Subject: macro variable to be inserted into maacro from other macro or File
hi all;
%get_job_dttm(jobnm=,manual_flag=,manual_run_dttm=);
so in the above macro i am passing values for the macro variables when i am
invoking it.
my task is i have to store the above macro variables
manual_flag,manual_run_dttm in other macro or store in other file.
how should i call that manual_flag,manual_run_dttm variables into
%get_job_dttm(jobnm='update').
purpose for storing this macro variables in other macro or file is that
they will be frequently changed and moreover i dont want to pass this
values directly at the macro ,instead i want to call it from other macro or
file where it is stored.
macro is this way;
%GLOBAL CURRENT_JOB_LASTRUNDTTM_DDS;
%GLOBAL RUN_CONTROL_DTTM_DDS;
/*
get_job_last_rundttm: To fetch the last successfull run dttm (start dttm)
for the job
1) job status table name will always be job_status
2) Library for job status will always be control & is defined in
autoexec.sas file
3) Parameters list
4) jobnm (Compulsory parameter), takes the job name. Should be enclosed
with
single quotes. E.g. 'POPULATE_FSC_PARTY_DIM'
5) manual_flag (Compulsory parameter), 'Y' if the manual datetime have been
specified,
'N' if the datetime has to be picked from job_status
6) manual_run_dttm (Optional), for initial loads this variable should
be set a value in the format ('01sep2004:00:00:00'dt)
*/
/*libname control "Data/misdata/control";*/
LIBNAME dds ORACLE PATH=ORASPO SCHEMA=spodds USER=spodds
PASSWORD='spodds' ;
%macro get_job_last_rundttm_dds (jobnm=,manual_run_dttm=,manual_flag=);
/*Initialize temporary variable start_time with large date*/
%let start_time = '01JAN5999:00:00:00'dt;
/*If statement starts here to check whether manual data is assigned or has
to
be taken from the job status */
%if %upcase(&manual_flag) = 'N' %then
/*%if %str(&manual_run_dttm) = %str() %then */
%do;
proc sql;
/*Select the maximum(job last start dttm) when the job was
successfull */
select catx("", "'", put(sttime, datetime21.), "'dt") into
:start_time from dds.dds_job_status
where left(trim(jobname)) = &jobnm
and (left(trim(jobstat)) = 'Job Successful' or left(trim(jobstat))
= 'Job Ended with Warnings')
group by jobname
having sttime = max(sttime);
quit;
%end;
%else
/*When the manual run data is supplied, assign the manual run data
to the
temporary variable start_time*/
%let start_time = &manual_run_dttm;
/*If statement ends here */
/*Assign the start time to CURRENT_JOB_LASTRUNDTTM macro variable*/
%let CURRENT_JOB_LASTRUNDTTM_DDS = &start_time;
%let RUN_CONTROL_DTTM_DDS = TODAY();
%mend get_job_last_rundttm_dds;
Thanks In advance