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