@sasjs/core 4.13.0 → 4.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -204,6 +204,7 @@ When contributing to this library, it is therefore important to ensure that all
204
204
 
205
205
  We are currently on major release v4. Breaking changes should be marked with the [deprecated](https://www.doxygen.nl/manual/commands.html#cmddeprecated) doxygen tag. The following changes are planned when the next major/breaking release (v5) becomes necessary:
206
206
 
207
+ * mf_getuniquelibref.sas to have the deprecated maxtried parameter removed (no longer needed)
207
208
  * mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
208
209
  * `insert_cmplib` option of mcf_xxx macros will be deprecated (the option is now checked automatically with value inserted only if needed)
209
210
  * mcf_xxx macros to have `wrap=` option defaulted to YES for convenience. Set this option explicitly to avoid issues.
@@ -14,27 +14,44 @@
14
14
 
15
15
  > mclib3
16
16
 
17
- @param prefix= first part of libref. Remember that librefs can only be 8 characters,
18
- so a 7 letter prefix would mean that maxtries should be 10.
19
- @param maxtries= the last part of the libref. Provide an integer value.
17
+ A blank value is returned if no usable libname is determined.
18
+
19
+ @param [in] prefix= (mclib) first part of the returned libref. As librefs can
20
+ be as long as 8 characters, a maximum length of 7 characters is premitted
21
+ for this prefix.
22
+ @param [in] maxtries= Deprecated parameter. Remains here to ensure a
23
+ non-breaking change. Will be removed in v5.
20
24
 
21
25
  @version 9.2
22
26
  @author Allan Bowe
23
27
  **/
24
28
 
25
-
26
29
  %macro mf_getuniquelibref(prefix=mclib,maxtries=1000);
27
- %local x libref;
28
- %let x=0;
29
- %do x=0 %to &maxtries;
30
- %if %sysfunc(libref(&prefix&x)) ne 0 %then %do;
31
- %let libref=&prefix&x;
32
- %let rc=%sysfunc(libname(&libref,%sysfunc(pathname(work))));
33
- %if &rc %then %put %sysfunc(sysmsg());
34
- &prefix&x
35
- %*put &sysmacroname: Libref &libref assigned as WORK and returned;
30
+ %local x;
31
+
32
+ %if ( %length(&prefix) gt 7 ) %then %do;
33
+ %put %str(ERR)OR: The prefix parameter cannot exceed 7 characters.;
34
+ 0
35
+ %return;
36
+ %end;
37
+ %else %if (%sysfunc(NVALID(&prefix,v7))=0) %then %do;
38
+ %put %str(ERR)OR: Invalid prefix (&prefix);
39
+ 0
36
40
  %return;
37
41
  %end;
42
+
43
+ /* Set maxtries equal to '10 to the power of [# unused characters] - 1' */
44
+ %let maxtries=%eval(10**(8-%length(&prefix))-1);
45
+
46
+ %do x = 0 %to &maxtries;
47
+ %if %sysfunc(libref(&prefix&x)) ne 0 %then %do;
48
+ &prefix&x
49
+ %return;
50
+ %end;
51
+ %let x = %eval(&x + 1);
38
52
  %end;
39
- %put unable to find available libref in range &prefix.0-&maxtries;
53
+
54
+ %put %str(ERR)OR: No usable libref in range &prefix.0-&maxtries;
55
+ %put %str(ERR)OR- Try reducing the prefix or deleting some libraries!;
56
+ 0
40
57
  %mend mf_getuniquelibref;
@@ -104,7 +104,9 @@
104
104
 
105
105
  %let ds=&syslast;
106
106
 
107
- proc compare base=&scopeds compare=&ds;
107
+ proc compare
108
+ base=&scopeds(where=(upcase(name) not in (%mf_getquotedstr(&ilist))))
109
+ compare=&ds;
108
110
  run;
109
111
 
110
112
  %if &sysinfo=0 %then %do;
@@ -48,6 +48,11 @@
48
48
  outfile=0
49
49
  )/*/STORE SOURCE*/;
50
50
 
51
+ %if "%substr(&sysver,1,4)"="V.04" %then %do;
52
+ %put %str(ERR)OR: Viya 4 does not support the IO library in lua;
53
+ %return;
54
+ %end;
55
+
51
56
  %ml_gsubfile()
52
57
 
53
58
  %mend mp_gsubfile;
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "@sasjs/cli": "3.6.0",
37
37
  "@sasjs/core": "4.4.7"
38
38
  },
39
- "version": "4.13.0"
39
+ "version": "4.15.0"
40
40
  }
@@ -0,0 +1,32 @@
1
+ /**
2
+ @file
3
+ @brief Gets a file from SASjs Drive
4
+ @details Fetches a file on SASjs Drive and stores it in the output fileref.
5
+
6
+ Example:
7
+
8
+ %ms_getfile(/some/stored/file.ext, outref=myfile)
9
+
10
+ @param [in] driveloc The full path to the file in SASjs Drive
11
+ @param [out] outref= (msgetfil) The fileref to contain the file.
12
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
13
+
14
+
15
+ **/
16
+
17
+ %macro ms_getfile(driveloc
18
+ ,outref=msgetfil
19
+ ,mdebug=0
20
+ );
21
+
22
+ filename &outref temp;
23
+
24
+ proc http method='GET' out=&outref
25
+ url="&_sasjs_apiserverurl/SASjsApi/drive/file?filePath=&driveloc";
26
+ %if &mdebug=1 %then %do;
27
+ debug level=2;
28
+ %end;
29
+ run;
30
+
31
+
32
+ %mend ms_getfile;
@@ -8,10 +8,16 @@
8
8
  %mv_deleteviyafolder(path=/Public/test)
9
9
 
10
10
 
11
- @param path= The full path of the folder to be deleted
12
- @param access_token_var= The global macro variable to contain the access token
13
- @param grant_type= valid values are "password" or "authorization_code" (unquoted).
14
- The default is authorization_code.
11
+ @param [in] path= The full path of the folder to be deleted
12
+ @param [in] access_token_var= (ACCESS_TOKEN) The global macro variable to
13
+ contain the access token
14
+ @param [in] grant_type= (sas_services) Valid values are:
15
+ @li password
16
+ @li authorization_code
17
+ @li detect - will check if access_token exists, if not will use sas_services
18
+ if a SASStudioV session else authorization_code. Default option.
19
+ @li sas_services - will use oauth_bearer=sas_services.
20
+ @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
15
21
 
16
22
 
17
23
  @version VIYA V.03.04
@@ -29,6 +35,7 @@
29
35
  %macro mv_deleteviyafolder(path=
30
36
  ,access_token_var=ACCESS_TOKEN
31
37
  ,grant_type=sas_services
38
+ ,mdebug=0
32
39
  );
33
40
  %local oauth_bearer;
34
41
  %if &grant_type=detect %then %do;
@@ -105,14 +112,17 @@ run;
105
112
  %let libref1a=%mf_getuniquelibref();
106
113
  libname &libref1a JSON fileref=&fname1a;
107
114
 
108
- data _null_;
109
- set &libref1a..items_links;
110
- if href=:'/folders/folders' then return;
111
- if rel='deleteResource' then
112
- call execute('proc http method="DELETE" url='!!quote("&base_uri"!!trim(href))
113
- !!'; headers "Authorization"="Bearer &&&access_token_var" '
114
- !!' "Accept"="*/*";run; /**/');
115
- run;
115
+ %if %mf_existds(&libref1a..items_links) %then %do;
116
+ data _null_;
117
+ set &libref1a..items_links;
118
+ if href=:'/folders/folders' then return;
119
+ if rel='deleteResource' then
120
+ call execute('proc http method="DELETE" url='
121
+ !!quote("&base_uri"!!trim(href))
122
+ !!'; headers "Authorization"="Bearer &&&access_token_var" '
123
+ !!' "Accept"="*/*";run; /**/');
124
+ run;
125
+ %end;
116
126
 
117
127
  %put &sysmacroname: perform the delete operation ;
118
128
  %local fname2;
@@ -133,9 +143,11 @@ run;
133
143
  %end;
134
144
  %else %put &sysmacroname: &path successfully deleted;
135
145
 
136
- /* clear refs */
137
- filename &fname1 clear;
138
- filename &fname2 clear;
139
- libname &libref1 clear;
146
+ %if &mdebug=0 %then %do;
147
+ /* clear refs */
148
+ filename &fname1 clear;
149
+ filename &fname2 clear;
150
+ libname &libref1 clear;
151
+ %end;
140
152
 
141
- %mend mv_deleteviyafolder;
153
+ %mend mv_deleteviyafolder;
@@ -33,7 +33,6 @@
33
33
  @li mf_getplatform.sas
34
34
  @li mf_getuniquefileref.sas
35
35
  @li mv_getfoldermembers.sas
36
- @li ml_json.sas
37
36
 
38
37
  **/
39
38
 
@@ -44,7 +43,7 @@
44
43
  ,grant_type=sas_services
45
44
  ,mdebug=0
46
45
  );
47
- %local dbg;
46
+ %local dbg bufsize varcnt fname1 fname2 errmsg;
48
47
  %if &mdebug=1 %then %do;
49
48
  %put &sysmacroname entry vars:;
50
49
  %put _local_;
@@ -104,7 +103,6 @@ run;
104
103
  )
105
104
 
106
105
  /* prepare request*/
107
- %local fname1;
108
106
  %let fname1=%mf_getuniquefileref();
109
107
  proc http method='GET' out=&fname1 &oauth_bearer
110
108
  url="&base_uri&joburi";
@@ -121,30 +119,81 @@ run;
121
119
  ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
122
120
  )
123
121
  %end;
124
- %local fname2 fname3 fpath1 fpath2 fpath3;
122
+
125
123
  %let fname2=%mf_getuniquefileref();
126
- %let fname3=%mf_getuniquefileref();
127
- %let fpath1=%sysfunc(pathname(&fname1));
128
- %let fpath2=%sysfunc(pathname(&fname2));
129
- %let fpath3=%sysfunc(pathname(&fname3));
124
+ filename &fname2 temp ;
130
125
 
131
- /* compile the lua JSON module */
132
- %ml_json()
133
- /* read using LUA - this allows the code to be of any length */
126
+ /* cannot use lua IO package as not available in Viya 4 */
127
+ /* so use data step to read the JSON until the string `"code":"` is found */
134
128
  data _null_;
135
- file "&fpath3..lua";
136
- put '
137
- infile = io.open (sas.symget("fpath1"), "r")
138
- outfile = io.open (sas.symget("fpath2"), "w")
139
- io.input(infile)
140
- local resp=json.decode(io.read())
141
- local job=resp["code"]
142
- outfile:write(job)
143
- io.close(infile)
144
- io.close(outfile)
145
- ';
129
+ file &fname2 recfm=n;
130
+ infile &fname1 lrecl=1 recfm=n;
131
+ input sourcechar $ 1. @@;
132
+ format sourcechar hex2.;
133
+ retain startwrite 0;
134
+ if startwrite=0 and sourcechar='"' then do;
135
+ reentry:
136
+ input sourcechar $ 1. @@;
137
+ if sourcechar='c' then do;
138
+ reentry2:
139
+ input sourcechar $ 1. @@;
140
+ if sourcechar='o' then do;
141
+ input sourcechar $ 1. @@;
142
+ if sourcechar='d' then do;
143
+ input sourcechar $ 1. @@;
144
+ if sourcechar='e' then do;
145
+ input sourcechar $ 1. @@;
146
+ if sourcechar='"' then do;
147
+ input sourcechar $ 1. @@;
148
+ if sourcechar=':' then do;
149
+ input sourcechar $ 1. @@;
150
+ if sourcechar='"' then do;
151
+ putlog 'code found';
152
+ startwrite=1;
153
+ input sourcechar $ 1. @@;
154
+ end;
155
+ end;
156
+ else if sourcechar='c' then goto reentry2;
157
+ end;
158
+ end;
159
+ else if sourcechar='"' then goto reentry;
160
+ end;
161
+ else if sourcechar='"' then goto reentry;
162
+ end;
163
+ else if sourcechar='"' then goto reentry;
164
+ end;
165
+ else if sourcechar='"' then goto reentry;
166
+ end;
167
+ /* once the `"code":"` string is found, write until unescaped `"` is found */
168
+ if startwrite=1 then do;
169
+ if sourcechar='\' then do;
170
+ input sourcechar $ 1. @@;
171
+ if sourcechar in ('"','\') then put sourcechar char1.;
172
+ else if sourcechar='n' then put '0A'x;
173
+ else if sourcechar='r' then put '0D'x;
174
+ else if sourcechar='t' then put '09'x;
175
+ else if sourcechar='u' then do;
176
+ length uni $4;
177
+ input uni $ 4. @@;
178
+ sourcechar=unicode('\u'!!uni);
179
+ put sourcechar char1.;
180
+ end;
181
+ else do;
182
+ call symputx('errmsg',"Uncaught escape char: "!!sourcechar,'l');
183
+ call symputx('syscc',99);
184
+ stop;
185
+ end;
186
+ end;
187
+ else if sourcechar='"' then stop;
188
+ else put sourcechar char1.;
189
+ end;
146
190
  run;
147
- %inc "&fpath3..lua";
191
+
192
+ %mp_abort(iftrue=("&syscc"="99")
193
+ ,mac=mv_getjobcode
194
+ ,msg=%str(&errmsg)
195
+ )
196
+
148
197
  /* export to desired destination */
149
198
  %if "&outref"="0" %then %do;
150
199
  data _null_;
@@ -169,7 +218,6 @@ run;
169
218
  /* clear refs */
170
219
  filename &fname1 clear;
171
220
  filename &fname2 clear;
172
- filename &fname3 clear;
173
221
  %end;
174
222
 
175
223
  %mend mv_getjobcode;
@@ -86,7 +86,8 @@
86
86
  @li mp_abort.sas
87
87
  @li mf_getplatform.sas
88
88
  @li mf_existfileref.sas
89
- @li ml_json.sas
89
+ @li mf_getuniquefileref.sas
90
+ @li mf_getuniquelibref.sas
90
91
 
91
92
  **/
92
93
 
@@ -95,7 +96,7 @@
95
96
  ,grant_type=sas_services
96
97
  ,mdebug=0
97
98
  );
98
- %local dbg;
99
+ %local dbg libref1 libref2 loglocation fname1 fname2;
99
100
  %if &mdebug=1 %then %do;
100
101
  %put &sysmacroname entry vars:;
101
102
  %put _local_;
@@ -154,8 +155,8 @@ options noquotelenmax;
154
155
  %let base_uri=%mf_getplatform(VIYARESTAPI);
155
156
 
156
157
  /* prepare request*/
157
- %local fname1;
158
158
  %let fname1=%mf_getuniquefileref();
159
+ %let fname2=%mf_getuniquefileref();
159
160
  proc http method='GET' out=&fname1 &oauth_bearer
160
161
  url="&base_uri&uri";
161
162
  headers
@@ -175,37 +176,19 @@ run;
175
176
  ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
176
177
  )
177
178
  %end;
178
- %local fname2 fname3 fpath1 fpath2 fpath3;
179
- %let fname2=%mf_getuniquefileref();
180
- %let fname3=%mf_getuniquefileref();
181
- %let fpath1=%sysfunc(pathname(&fname1));
182
- %let fpath2=%sysfunc(pathname(&fname2));
183
- %let fpath3=%sysfunc(pathname(&fname3));
184
-
185
- /* compile the lua JSON module */
186
- %ml_json()
187
- /* read using LUA - this allows the code to be of any length */
179
+
180
+ %let libref1=%mf_getuniquelibref();
181
+ libname &libref1 JSON fileref=&fname1;
188
182
  data _null_;
189
- file "&fpath3..lua";
190
- put '
191
- infile = io.open (sas.symget("fpath1"), "r")
192
- outfile = io.open (sas.symget("fpath2"), "w")
193
- io.input(infile)
194
- local resp=json.decode(io.read())
195
- local logloc=resp["logLocation"]
196
- outfile:write(logloc)
197
- io.close(infile)
198
- io.close(outfile)
199
- ';
183
+ set &libref1..root;
184
+ call symputx('loglocation',loglocation,'l');
200
185
  run;
201
- %inc "&fpath3..lua";
202
- /* get log path*/
186
+
187
+ /* validate log path*/
203
188
  %let errflg=1;
204
- %let errmsg=No entry in &fname2 fileref;
189
+ %let errmsg=No loglocation entry in &fname1 fileref;
205
190
  data _null_;
206
- infile &fname2;
207
- input;
208
- uri=cats(_infile_);
191
+ uri=symget('loglocation');
209
192
  if length(uri)<12 then do;
210
193
  call symputx('errflg',1);
211
194
  call symputx('errmsg',"URI is invalid (too short) - '&uri'",'l');
@@ -232,7 +215,7 @@ run;
232
215
 
233
216
  /* we have a log uri - now fetch the log */
234
217
  %&dbg.put &sysmacroname: querying &base_uri&logloc/content;
235
- proc http method='GET' out=&fname1 &oauth_bearer
218
+ proc http method='GET' out=&fname2 &oauth_bearer
236
219
  url="&base_uri&logloc/content?limit=10000";
237
220
  headers
238
221
  %if &grant_type=authorization_code %then %do;
@@ -243,14 +226,14 @@ run;
243
226
 
244
227
  %if &mdebug=1 %then %do;
245
228
  %put &sysmacroname: fetching log content from &base_uri&logloc/content;
246
- data _null_;infile &fname1;input;putlog _infile_;run;
229
+ data _null_;infile &fname2;input;putlog _infile_;run;
247
230
  %end;
248
231
 
249
232
  %if &SYS_PROCHTTP_STATUS_CODE=400 %then %do;
250
233
  /* fetch log from parent session */
251
234
  %let logloc=%substr(&logloc,1,%index(&logloc,%str(/jobs/))-1);
252
235
  %&dbg.put &sysmacroname: Now querying &base_uri&logloc/log/content;
253
- proc http method='GET' out=&fname1 &oauth_bearer
236
+ proc http method='GET' out=&fname2 &oauth_bearer
254
237
  url="&base_uri&logloc/log/content?limit=10000";
255
238
  headers
256
239
  %if &grant_type=authorization_code %then %do;
@@ -260,47 +243,32 @@ run;
260
243
  run;
261
244
  %if &mdebug=1 %then %do;
262
245
  %put &sysmacroname: fetching log content from &base_uri&logloc/log/content;
263
- data _null_;infile &fname1;input;putlog _infile_;run;
246
+ data _null_;infile &fname2;input;putlog _infile_;run;
264
247
  %end;
265
248
  %end;
266
249
 
267
250
  %if &SYS_PROCHTTP_STATUS_CODE ne 200 and &SYS_PROCHTTP_STATUS_CODE ne 201
268
251
  %then %do;
269
252
  %if &mdebug ne 1 %then %do; /* have already output above */
270
- data _null_;infile &fname1;input;putlog _infile_;run;
253
+ data _null_;infile &fname2;input;putlog _infile_;run;
271
254
  %end;
272
255
  %mp_abort(mac=&sysmacroname
273
256
  ,msg=%str(logfetch: &SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
274
257
  )
275
258
  %end;
276
- data _null_;
277
- file "&fpath3..lua";
278
- put '
279
- infile = io.open (sas.symget("fpath1"), "r")
280
- outfile = io.open (sas.symget("fpath2"), "w")
281
- io.input(infile)
282
- local resp=json.decode(io.read())
283
- for i, v in pairs(resp["items"]) do
284
- outfile:write(v.line,"\n")
285
- end
286
- io.close(infile)
287
- io.close(outfile)
288
- ';
289
- run;
290
- %inc "&fpath3..lua";
291
259
 
292
- /* write log out to the specified fileref */
260
+ %let libref2=%mf_getuniquelibref();
261
+ libname &libref2 JSON fileref=&fname2;
293
262
  data _null_;
294
- infile &fname2 end=last;
295
263
  file &outref mod;
296
264
  if _n_=1 then do;
297
265
  put "/** SASJS Viya Job Log Extract start: &uri **/";
298
266
  end;
299
- input;
300
- put _infile_;
267
+ set &libref2..items end=last;
301
268
  %if &mdebug=1 %then %do;
302
- putlog _infile_;
269
+ putlog line;
303
270
  %end;
271
+ put line;
304
272
  if last then do;
305
273
  put "/** SASJS Viya Job Log Extract end: &uri **/";
306
274
  end;
@@ -309,7 +277,8 @@ run;
309
277
  %if &mdebug=0 %then %do;
310
278
  filename &fname1 clear;
311
279
  filename &fname2 clear;
312
- filename &fname3 clear;
280
+ libname &libref1 clear;
281
+ libname &libref2 clear;
313
282
  %end;
314
283
  %else %do;
315
284
  %put &sysmacroname exit vars:;
@@ -1,110 +0,0 @@
1
- /**
2
- @file
3
- @brief Provides a replacement for the stpsrv_header function
4
- @details The stpsrv_header is normally a built-in function, used to set the
5
- headers for SAS 9 Stored Processes as documented here:
6
- https://go.documentation.sas.com/doc/en/itechcdc/9.4/stpug/srvhead.htm
7
-
8
- The purpose of this custom function is to provide a replacement when running
9
- similar code as a web service against
10
- [sasjs/server](https://github.com/sasjs/server). It operates by creating a
11
- text file with the headers. The location of this text file is determined by
12
- a macro variable (`sasjs_stpsrv_header_loc`) which needs to be injected into
13
- each service by the calling process, eg:
14
-
15
- %let sasjs_stpsrv_header_loc = C:/temp/some_uuid/stpsrv_header.txt;
16
-
17
- Note - the function works by appending headers to the file. If multiple same-
18
- named headers are provided, they will all be appended - the calling process
19
- needs to pick up the last one. This will mean removing the attribute if the
20
- final record has an empty value.
21
-
22
- The function takes the following (positional) parameters:
23
-
24
- | PARAMETER | DESCRIPTION |
25
- |------------|-------------|
26
- | name $ | name of the header attribute to create|
27
- | value $ | value of the header attribute|
28
-
29
- It returns 0 if successful, or -1 if an error occured.
30
-
31
- Usage:
32
-
33
- %let sasjs_stpsrv_header_loc=%sysfunc(pathname(work))/stpsrv_header.txt;
34
-
35
- %mcf_stpsrv_header(wrap=YES, insert_cmplib=YES)
36
-
37
- data _null_;
38
- rc=stpsrv_header('Content-type','application/text');
39
- rc=stpsrv_header('Content-disposition',"attachment; filename=file.txt");
40
- run;
41
-
42
- data _null_;
43
- infile "&sasjs_stpsrv_header_loc";
44
- input;
45
- putlog _infile_;
46
- run;
47
-
48
-
49
- @param [out] wrap= (NO) Choose YES to add the proc fcmp wrapper.
50
- @param [out] lib= (work) The output library in which to create the catalog.
51
- @param [out] cat= (sasjs) The output catalog in which to create the package.
52
- @param [out] pkg= (utils) The output package in which to create the function.
53
- Uses a 3 part format: libref.catalog.package
54
- @param [out] insert_cmplib= DEPRECATED - The CMPLIB option is checked and
55
- values inserted only if needed.
56
-
57
- <h4> SAS Macros </h4>
58
- @li mcf_init.sas
59
-
60
- <h4> Related Programs </h4>
61
- @li mcf_stpsrv_header.test.sas
62
- @li mp_init.sas
63
-
64
- **/
65
-
66
- %macro mcf_stpsrv_header(wrap=NO
67
- ,insert_cmplib=DEPRECATED
68
- ,lib=WORK
69
- ,cat=SASJS
70
- ,pkg=UTILS
71
- )/*/STORE SOURCE*/;
72
- %local i var cmpval found;
73
- %if %mcf_init(stpsrv_header)=1 %then %return;
74
-
75
- %if &wrap=YES %then %do;
76
- proc fcmp outlib=&lib..&cat..&pkg;
77
- %end;
78
-
79
- function stpsrv_header(name $, value $);
80
- length loc $128 val $512;
81
- loc=symget('sasjs_stpsrv_header_loc');
82
- val=trim(name)!!': '!!value;
83
- length fref $8;
84
- rc=filename(fref,loc);
85
- if (rc ne 0) then return( -1 );
86
- fid = fopen(fref,'a');
87
- if (fid = 0) then return( -1 );
88
- rc=fput(fid, val);
89
- rc=fwrite(fid);
90
- rc=fclose(fid);
91
- rc=filename(fref);
92
- return(0);
93
- endsub;
94
-
95
- %if &wrap=YES %then %do;
96
- quit;
97
- %end;
98
-
99
- /* insert the CMPLIB if not already there */
100
- %let cmpval=%sysfunc(getoption(cmplib));
101
- %let found=0;
102
- %do i=1 %to %sysfunc(countw(&cmpval,%str( %(%))));
103
- %let var=%scan(&cmpval,&i,%str( %(%)));
104
- %if &var=&lib..&cat %then %let found=1;
105
- %end;
106
- %if &found=0 %then %do;
107
- options insert=(CMPLIB=(&lib..&cat));
108
- %end;
109
-
110
- %mend mcf_stpsrv_header;