Purpose
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));
%end;
%else %do;
  
%let outsubpath=&outdest;
%end;
%if &sysenv =BACK and %nrbquote(&nodesc)= %nrbquote() %then %do;
   
%let run_desc=%sysfunc(sysget(rundesc));
%end;
*check if output directory exists if not create it;
/*%if %sysfunc(fileexist(&outpath.\&outsubpath.))=0 %then %do;
  systask command "mkdir &outpath.\&outsubpath." nowait;
%end;*/

%if %nrbquote(&validation) ne %nrbquote() %then %do;
%let scrimacv = &scrimac\validation;            * global development macro library - validation;
libname v_adam
"&path\ADAM\validation\data";
libname v_sdtm
"&path\sdtm\validation\data";
%end;
   
libname p_adam
"&path\ADAM\Production\data";
libname p_sdtm
"&path\sdtm\Production\data";
libname raw
"&root.\&studyid.\raw\sasdata";
libname joblog
"&path.\runlog";
libname impdata
"&dataimppath";
libname profunc
"&projfunc";
libname metasdtm
"&path\metadata\sdtm";
libname glometa
"&root\_global_metadata";
options mautolocdisplay mautosource fmtsearch=(meta)  cmplib=profunc.funcs noquotelenmax nonumber nodate;

options    sasautos= (
"&root.\&studyid.\macro"
  
"&root.\_project_macros"
       
"!SASROOT\core\sasmacro"
       
"!SASROOT\aacomp\sasmacro"
       
"!SASROOT\accelmva\sasmacro"
       
"!SASROOT\dmscore\sasmacro"
       
"!SASROOT\graph\sasmacro"
       
"!SASROOT\hps\sasmacro"
       
"!SASROOT\stat\sasmacro"
        );
%project_formats;
%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;
%mend;