Sets up the environment for a specified study
Runs a study setup macro which defines study specific macro variables
Runs study formats for reporting
Creates outsubpath variable for use in standard reports, this is overridden by jobs ran using the Batch macros to allow outputs to be rerouted e.g. for safety reviews.

Name Description Default Scope
Root Drive letter for paths S: Global
Studyid Name of main study directory None Global
outdest Output path default &root\&studyid\TFL\production\Output
%macro assign(root=s:,studyid=,spoprot=,sponame=,outdest=,validation=,noroute=,nodesc=y);
%global path study sponname sponprot projmac macrpath outpath mshell_path outsubpath poptitle run_desc metapath dataimppath;
%let path =&root.\&studyid.\Deliverable;
%let metapath=&path\metadata;
%let metasdtm=&path\metadata\sdtm;
%let dataimppath=&root.\&studyid.\data\imported;
%let study=&studyid.;
%let macrpath=&root.\&studyid.\macro;
%let sponname=&sponame;
%let sponprot=&spoprot;
%let projmac = &root\_project_macros;
%let projfunc = &root\_project_functions;
%let scrimac  = &root\scrimac;                 * global macro library path;
%let scrimacp = &scrimac\production;            * global development macro library - production;
%let scrimacd = &scrimac\development;           * global development macro library - dev;
%let outpath=&path.\TFL\production\Output;
%let mshell_path=&root.\&studyid.;

%if &sysenv =BACK and %nrbquote(&noroute)= %nrbquote() %then %do;
%let outsubpath=%sysfunc(sysget(outsubpath));
%else %do;
%let outsubpath=&outdest;
%if &sysenv =BACK and %nrbquote(&nodesc)= %nrbquote() %then %do;
%let run_desc=%sysfunc(sysget(rundesc));
*check if output directory exists if not create it;
/*%if %sysfunc(fileexist(&outpath.\&outsubpath.))=0 %then %do;
  systask command "mkdir &outpath.\&outsubpath." nowait;

%if %nrbquote(&validation) ne %nrbquote() %then %do;
%let scrimacv = &scrimac\validation;            * global development macro library - validation;
libname v_adam
libname v_sdtm
libname p_adam
libname p_sdtm
libname raw
libname joblog
libname impdata
libname profunc
libname metasdtm
libname glometa
options mautolocdisplay mautosource fmtsearch=(meta)  cmplib=profunc.funcs noquotelenmax nonumber nodate;

options    sasautos= (
%if %fexist(fpath=s:\&studyid.\macro\,fname=study_formats)=1 %then %study_formats;
%if %fexist(fpath=s:\&studyid.\macro\,fname=study_detail)=1 %then %study_detail;