Macros for SAS Application Developers
https://github.com/sasjs/core
mx_createwebservice.sas
Go to the documentation of this file.
1 /**
2  @file mx_createwebservice.sas
3  @brief Create a web service in SAS 9, Viya or SASjs
4  @details Creates a SASJS ready Stored Process in SAS 9, a Job Execution
5  Service in SAS Viya, or a Stored Program on SASjs Server - depending on the
6  executing environment.
7 
8 Usage:
9 
10  %* compile macros ;
11  filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
12  %inc mc;
13 
14  %* write some code;
15  filename ft15f001 temp;
16  parmcards4;
17  %* fetch any data from frontend ;
18  %webout(FETCH)
19  data example1 example2;
20  set sashelp.class;
21  run;
22  %* send data back;
23  %webout(OPEN)
24  %webout(ARR,example1) * Array format, fast, suitable for large tables ;
25  %webout(OBJ,example2) * Object format, easier to work with ;
26  %webout(CLOSE)
27  ;;;;
28 
29  %* create the service (including webout macro and dependencies);
30  %mx_createwebservice(path=/Public/app/common,name=appInit,replace=YES)
31 
32  <h4> SAS Macros </h4>
33  @li mf_getplatform.sas
34  @li mm_createwebservice.sas
35  @li ms_createwebservice.sas
36  @li mv_createwebservice.sas
37 
38  @param [in,out] path= The full folder path where the service will be created
39  @param [in,out] name= Service name. Avoid spaces.
40  @param [in] desc= The description of the service (optional)
41  @param [in] precode= Space separated list of filerefs, pointing to the code
42  that needs to be attached to the beginning of the service (optional)
43  @param [in] code= (ft15f001) Space seperated fileref(s) of the actual code to
44  be added
45  @param [in] replace= (YES) Select YES to replace any existing service in that
46  location
47  @param [in] mDebug= (0) set to 1 to show debug messages in the log
48 
49  @author Allan Bowe
50 
51 **/
52 
53 %macro mx_createwebservice(path=HOME
54  ,name=initService
55  ,precode=
56  ,code=ft15f001
57  ,desc=This service was created by the mp_createwebservice macro
58  ,replace=YES
59  ,mdebug=0
60 )/*/STORE SOURCE*/;
61 
62 %if &syscc ge 4 %then %do;
63  %put syscc=&syscc - &sysmacroname will not execute in this state;
64  %return;
65 %end;
66 
67 %local platform; %let platform=%mf_getplatform();
68 %if &platform=SASVIYA %then %do;
69  %if "&path"="HOME" %then %let path=/Users/&sysuserid/My Folder;
70  %mv_createwebservice(path=&path
71  ,name=&name
72  ,code=&code
73  ,precode=&precode
74  ,desc=&desc
75  ,replace=&replace
76  )
77 %end;
78 %else %if &platform=SASJS %then %do;
79  %if "&path"="HOME" %then %let path=/Users/&_sasjs_username/My Folder;
80  %ms_createwebservice(path=&path
81  ,name=&name
82  ,code=&code
83  ,precode=&precode
84  ,mdebug=&mdebug
85  )
86 %end;
87 %else %do;
88  %if "&path"="HOME" %then %let path=/User Folders/&_METAPERSON/My Folder;
89  %mm_createwebservice(path=&path
90  ,name=&name
91  ,code=&code
92  ,precode=&precode
93  ,desc=&desc
94  ,replace=&replace
95  )
96 %end;
97 
98 %mend mx_createwebservice;