Macros for SAS Application Developers
https://github.com/sasjs/core
mx_getcode.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Fetches code from Viya Job, SAS 9 STP, or SASjs Server STP
4  @details When building applications that run on multiple flavours of SAS, it
5  is convenient to use a single macro (like this one) to fetch the source
6  code from a Viya Job, SAS 9 Stored Process, or SASjs Stored Program.
7 
8  The alternative would be to compile a generic macro in target-specific
9  folders (SASVIYA, SAS9 and SASJS). This avoids compiling unnecessary macros
10  at the expense of a more complex sasjsconfig.json setup.
11 
12 
13  @param [in] loc The full path to the Viya Job, SAS 9 Stored Process or SASjs
14  Stored Program in Drive or Metadata, WITHOUT the .sas extension (SASjs only)
15  @param [out] outref= (0) The fileref to create, which will contain the source
16  code.
17 
18  <h4> SAS Macros </h4>
19  @li mf_getplatform.sas
20  @li mm_getstpcode.sas
21  @li ms_getfile.sas
22  @li mv_getjobcode.sas
23 
24  @author Allan Bowe
25 
26 **/
27 
28 %macro mx_getcode(loc,outref=0
29 )/*/STORE SOURCE*/;
30 
31 %local platform name shortloc;
32 %let platform=%mf_getplatform();
33 
34 %if &platform=SASJS %then %do;
35  %ms_getfile(&loc..sas, outref=&outref)
36 %end;
37 %else %if &platform=SAS9 or &platform=SASMETA %then %do;
38  %mm_getstpcode(tree=&loc,outref=&outref)
39 %end;
40 %else %if &platform=SASVIYA %then %do;
41  /* extract name & path from &loc */
42  data _null_;
43  loc=symget('loc');
44  name=scan(loc,-1,'/');
45  shortloc=substr(loc,1,length(loc)-length(name)-1);
46  call symputx('name',name,'l');
47  call symputx('shortloc',shortloc,'l');
48  run;
49  %mv_getjobcode(
50  path=&shortloc,
51  name=&name,
52  outref=&outref
53  )
54 %end;
55 %else %put &sysmacroname: &platform is unsupported!!!;
56 
57 %mend mx_getcode;