@sasjs/core 4.59.5 → 4.59.6
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 +8 -14
- package/base/mp_assertscope.sas +4 -4
- package/package.json +1 -1
- package/viya/mv_createfile.sas +76 -9
- package/viya/mv_getviyafileextparms.sas +247 -0
package/README.md
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
# Macro Core
|
|
2
|
-
|
|
3
|
-
[](http://npmjs.org/package/@sasjs/core)
|
|
4
|
+
[](https://github.com/sasjs/core/blob/main/.github/workflows/main.yml)
|
|
4
5
|

|
|
5
6
|

|
|
6
7
|
[](https://github.com/sasjs/core/issues?q=is%3Aissue+is%3Aclosed)
|
|
7
8
|
[](https://github.com/sasjs/core/issues)
|
|
8
9
|

|
|
9
|
-
[](https://gitpod.io/#https://github.com/sasjs/core)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
[npm-image]:https://img.shields.io/npm/v/@sasjs/core.svg
|
|
13
|
-
[npm-url]:http://npmjs.org/package/@sasjs/core
|
|
14
|
-
[githubworkflow-image]:https://github.com/sasjs/core/actions/workflows/main.yml/badge.svg
|
|
15
|
-
[githubworkflow-url]:https://github.com/sasjs/core/blob/main/.github/workflows/main.yml
|
|
16
|
-
[dependency-url]:https://github.com/sasjs/core/blob/main/package.json
|
|
17
10
|
|
|
18
11
|
|
|
19
12
|
Much quality. Many standards. The **Macro Core** library exists to save time and development effort! Herein ye shall find a veritable host of MIT-licenced, production quality SAS macros. These are a mix of tools, utilities, functions and code generators that are useful in the context of [Application Development](https://sasapps.io) on the SAS platform (eg https://datacontroller.io). [Contributions](https://github.com/sasjs/core/blob/main/.github/CONTRIBUTING.md) are welcome.
|
|
@@ -220,12 +213,13 @@ When contributing to this library, it is therefore important to ensure that all
|
|
|
220
213
|
|
|
221
214
|
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:
|
|
222
215
|
|
|
223
|
-
*
|
|
224
|
-
* mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
|
|
225
|
-
* `insert_cmplib` option of mcf_xxx macros will be deprecated (the option is now checked automatically with value inserted only if needed)
|
|
216
|
+
* mcf_xxx macros to have `insert_cmplib` option deprecated (the option is now checked automatically with value inserted only if needed)
|
|
226
217
|
* mcf_xxx macros to have `wrap=` option defaulted to YES for convenience. Set this option explicitly to avoid issues.
|
|
227
|
-
*
|
|
218
|
+
* mf_getuniquelibref.sas to have the deprecated maxtries parameter removed (no longer needed)
|
|
219
|
+
* mp_abort.sas will have the redundant type= parameter removed.
|
|
228
220
|
* mp_coretable.sas will be replaced by the standalone macros in the `ddl` folder (which are already available)
|
|
221
|
+
* mp_getddl.sas to be renamed to mp_ds2ddl.sas (consistent with other ds2xxx macros). A wrapper macro is already in place, and you are able to use this immediately. The default for SHOWLOG will also be YES instead of NO.
|
|
222
|
+
* mp_testservice.sas to be renamed as mp_execute.sas (as it doesn't actually test anything)
|
|
229
223
|
|
|
230
224
|
## Star Gazing
|
|
231
225
|
|
package/base/mp_assertscope.sas
CHANGED
|
@@ -73,10 +73,6 @@
|
|
|
73
73
|
ignorelist=,
|
|
74
74
|
outds=work.test_results
|
|
75
75
|
)/*/STORE SOURCE*/;
|
|
76
|
-
%local ds test_result test_comments del add mod ilist;
|
|
77
|
-
%let ilist=%upcase(&sasjs_prefix._FUNCTIONS SYS_PROCHTTP_STATUS_CODE
|
|
78
|
-
SYS_PROCHTTP_STATUS_CODE SYS_PROCHTTP_STATUS_PHRASE &ignorelist);
|
|
79
|
-
|
|
80
76
|
/**
|
|
81
77
|
* this sets up the global vars, it will also enter STRICT mode. If this
|
|
82
78
|
* behaviour is not desired, simply initiate the following global macro
|
|
@@ -84,6 +80,10 @@
|
|
|
84
80
|
*/
|
|
85
81
|
%mp_init()
|
|
86
82
|
|
|
83
|
+
%local ds test_result test_comments del add mod ilist;
|
|
84
|
+
%let ilist=%upcase(&sasjs_prefix._FUNCTIONS SYS_PROCHTTP_STATUS_CODE
|
|
85
|
+
SYS_PROCHTTP_STATUS_CODE SYS_PROCHTTP_STATUS_PHRASE &ignorelist);
|
|
86
|
+
|
|
87
87
|
/* get current variables */
|
|
88
88
|
%if &action=SNAPSHOT %then %do;
|
|
89
89
|
proc sql;
|
package/package.json
CHANGED
package/viya/mv_createfile.sas
CHANGED
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
@li mp_base64copy.sas
|
|
70
70
|
@li mp_replace.sas
|
|
71
71
|
@li mv_createfolder.sas
|
|
72
|
+
@li mv_getviyafileextparms.sas
|
|
72
73
|
|
|
73
74
|
<h4> Related Macros</h4>
|
|
74
75
|
@li mv_createfile.sas
|
|
@@ -153,7 +154,7 @@
|
|
|
153
154
|
|
|
154
155
|
options noquotelenmax;
|
|
155
156
|
%local base_uri; /* location of rest apis */
|
|
156
|
-
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
|
157
|
+
%let base_uri=%trim(%mf_getplatform(VIYARESTAPI));
|
|
157
158
|
|
|
158
159
|
/* create folder if it does not already exist */
|
|
159
160
|
%local folderds self_uri;
|
|
@@ -172,7 +173,7 @@ run;
|
|
|
172
173
|
/* abort or delete if file already exists */
|
|
173
174
|
%let force=%upcase(&force);
|
|
174
175
|
%local fileuri ;
|
|
175
|
-
%let fileuri=%mfv_getpathuri(&path/&name);
|
|
176
|
+
%let fileuri=%trim(%mfv_getpathuri(&path/&name));
|
|
176
177
|
%mp_abort(iftrue=(%mf_isblank(&fileuri)=0 and &force ne YES)
|
|
177
178
|
,mac=MV_CREATEFILE
|
|
178
179
|
,msg=%str(File &path/&name already exists and force=&force)
|
|
@@ -199,7 +200,13 @@ run;
|
|
|
199
200
|
|
|
200
201
|
%local url mimetype ext;
|
|
201
202
|
%let url=&base_uri/files/files?parentFolderUri=&self_uri;
|
|
202
|
-
%let ext=%upcase(%scan(&name,-1,.));
|
|
203
|
+
%let ext=%upcase(%trim(%scan(&name,-1,.)));
|
|
204
|
+
|
|
205
|
+
/* Get Viya file-extension details into some macro variables */
|
|
206
|
+
%mv_getViyaFileExtParms(&ext
|
|
207
|
+
,propertiesVar=viyaProperties
|
|
208
|
+
,typeDefNameVar=viyaTypeDefName
|
|
209
|
+
,mdebug=&mdebug);
|
|
203
210
|
|
|
204
211
|
/* fetch job info */
|
|
205
212
|
%local fname1;
|
|
@@ -212,12 +219,23 @@ proc http method='POST' out=&fname1 &oauth_bearer in=&fref
|
|
|
212
219
|
%else %do;
|
|
213
220
|
ct="&ctype"
|
|
214
221
|
%end;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
222
|
+
|
|
223
|
+
/* typeDefName */
|
|
224
|
+
%if not %mf_isBlank(&viyaTypeDefName) %then %do;
|
|
225
|
+
url="&url%str(&)typeDefName=&viyaTypeDefName";
|
|
218
226
|
%end;
|
|
219
227
|
%else %do;
|
|
220
|
-
|
|
228
|
+
%if "&ext"="HTM" or "&ext"="HTML" or "&ext"="XHTML" %then %do;
|
|
229
|
+
url="&url%str(&)typeDefName=file_html";
|
|
230
|
+
%end;
|
|
231
|
+
%else %do;
|
|
232
|
+
%if "&ext"="CSS" or "&ext"="JS" or "&ext"="PNG" or "&ext"="SVG" %then %do;
|
|
233
|
+
url="&url%str(&)typeDefName=file_%lowcase(&ext)";
|
|
234
|
+
%end;
|
|
235
|
+
%else %do;
|
|
236
|
+
url="&url";
|
|
237
|
+
%end;
|
|
238
|
+
%end;
|
|
221
239
|
%end;
|
|
222
240
|
|
|
223
241
|
headers "Accept"="application/json"
|
|
@@ -239,6 +257,7 @@ run;
|
|
|
239
257
|
,mac=MV_CREATEFILE
|
|
240
258
|
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
|
241
259
|
)
|
|
260
|
+
|
|
242
261
|
%local libref2;
|
|
243
262
|
%let libref2=%mf_getuniquelibref();
|
|
244
263
|
libname &libref2 JSON fileref=&fname1;
|
|
@@ -246,12 +265,60 @@ libname &libref2 JSON fileref=&fname1;
|
|
|
246
265
|
data &outds;
|
|
247
266
|
set &libref2..links end=last;
|
|
248
267
|
if rel='createChild' then do;
|
|
249
|
-
call symputx('href',quote(cats("&base_uri",href)),'l');
|
|
250
268
|
&dbg put (_all_)(=);
|
|
251
269
|
end;
|
|
252
270
|
run;
|
|
253
271
|
|
|
254
|
-
|
|
272
|
+
/* URI of the created file */
|
|
273
|
+
%let fileuri=%trim(%mfv_getpathuri(&path/&name));
|
|
274
|
+
|
|
275
|
+
/* If properties were found then patch the file to include them */
|
|
276
|
+
%if not %mf_isBlank(%superq(viyaProperties)) %then %do;
|
|
277
|
+
/* Wrap the properties object in a root object also containing the file name */
|
|
278
|
+
%local viyapatch;
|
|
279
|
+
%let viyapatch = %sysfunc(pathname(work))/%mf_getuniquename(prefix=patch_json_);
|
|
280
|
+
data _null_;
|
|
281
|
+
length line $32767;
|
|
282
|
+
file "&viyapatch" lrecl=32767;
|
|
283
|
+
put '{ "name": "' "&name" '",';
|
|
284
|
+
line = cat('"properties": ',symget("viyaProperties"));
|
|
285
|
+
put line;
|
|
286
|
+
put '}';
|
|
287
|
+
stop;
|
|
288
|
+
run;
|
|
289
|
+
|
|
290
|
+
%if &mdebug=1 %then %do;
|
|
291
|
+
data _null_;
|
|
292
|
+
if (_n_ eq 1) then put 'DEBUG: ** PATCH JSON **';
|
|
293
|
+
infile "&viyapatch" end=last;
|
|
294
|
+
input;
|
|
295
|
+
put _infile_;
|
|
296
|
+
run;
|
|
297
|
+
%end;
|
|
298
|
+
|
|
299
|
+
/* And apply the properties to the newly created file, using the PATCH method */
|
|
300
|
+
%let fref=%mf_getuniquefileref();
|
|
301
|
+
filename &fref "&viyapatch";
|
|
302
|
+
%let url=&base_uri&fileuri;
|
|
303
|
+
|
|
304
|
+
proc http method='PATCH' oauth_bearer=sas_services in=&fref
|
|
305
|
+
url="&url";
|
|
306
|
+
headers "Accept"="application/json"
|
|
307
|
+
"Content-Type"="application/json"
|
|
308
|
+
"If-Match"="*";
|
|
309
|
+
%if &mdebug=1 %then %do;
|
|
310
|
+
debug level=2;
|
|
311
|
+
%end;
|
|
312
|
+
run;
|
|
313
|
+
%if &mdebug=1 %then %put &sysmacroname PATCH &=url
|
|
314
|
+
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
|
315
|
+
%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200)
|
|
316
|
+
,mac=MV_CREATEFILE
|
|
317
|
+
,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
|
|
318
|
+
)
|
|
319
|
+
%end;
|
|
320
|
+
|
|
321
|
+
%put &sysmacroname: &base_uri&fileuri;
|
|
255
322
|
%put /SASJobExecution?_file=&path/&name;%put;
|
|
256
323
|
|
|
257
324
|
%if &mdebug=0 %then %do;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file mv_getviyafileextparms.sas
|
|
3
|
+
@brief Reads the VIYA file-extension type definition and returns selected
|
|
4
|
+
values in SAS macro variables
|
|
5
|
+
|
|
6
|
+
@details Content is derived from the following endpoint:
|
|
7
|
+
"https://${serverUrl}/types/types?limit=999999"
|
|
8
|
+
|
|
9
|
+
@param [in] ext File extension to retrieve property info for.
|
|
10
|
+
@param [out] propertiesVar= SAS macro variable name that will contain
|
|
11
|
+
the 'properties' object json, if found, else blank.
|
|
12
|
+
@param [out] typeDefNameVar= SAS macro variable name that will contain
|
|
13
|
+
the 'typeDefName' property value, if found, else blank.
|
|
14
|
+
@param [out] mediaTypeVar= SAS macro variable name that will contain
|
|
15
|
+
the 'mediaType' property value, if found, else blank.
|
|
16
|
+
@param [out] viyaFileExtRespLibDs (work.mv_getViyaFileExtParmsResponse)
|
|
17
|
+
Library.name of the dataset to receive the local working copy of the initial
|
|
18
|
+
response that requests all file extension details. Created once per session
|
|
19
|
+
to avoid multiple api calls.
|
|
20
|
+
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
|
21
|
+
|
|
22
|
+
<h4> SAS Macros </h4>
|
|
23
|
+
@li mf_existds.sas
|
|
24
|
+
@li mf_getplatform.sas
|
|
25
|
+
@li mf_getuniquefileref.sas
|
|
26
|
+
@li mf_getuniquename.sas
|
|
27
|
+
@li mf_getvalue.sas
|
|
28
|
+
@li mf_getvarlist.sas
|
|
29
|
+
@li mf_getvartype.sas
|
|
30
|
+
@li mf_nobs.sas
|
|
31
|
+
@li mp_abort.sas
|
|
32
|
+
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
%macro mv_getViyaFileExtParms(
|
|
36
|
+
ext,
|
|
37
|
+
typeDefNameVar=,
|
|
38
|
+
propertiesVar=,
|
|
39
|
+
mediaTypeVar=,
|
|
40
|
+
viyaFileExtRespLibDs=work.mv_getViyaFileExtParmsResponse,
|
|
41
|
+
mdebug=0
|
|
42
|
+
);
|
|
43
|
+
%local base_uri; /* location of rest apis */
|
|
44
|
+
%local url; /* File extension info end-point */
|
|
45
|
+
|
|
46
|
+
%mp_abort(
|
|
47
|
+
iftrue=(%mf_isBlank(&ext))
|
|
48
|
+
,msg=%str(No file extension provided.)
|
|
49
|
+
,mac=MV_GETVIYAFILEEXTPARMS
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
%mp_abort(
|
|
53
|
+
iftrue=(%mf_isBlank(&typeDefNameVar) and
|
|
54
|
+
%mf_isBlank(&propertiesVar) and
|
|
55
|
+
%mf_isBlank(&mediaTypeVar))
|
|
56
|
+
,msg=%str(MV_GETVIYAFILEEXTPARMS - No parameter was requested.)
|
|
57
|
+
,mac=MV_GETVIYAFILEEXTPARMS
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
%mp_abort(
|
|
61
|
+
iftrue=(%mf_isBlank(&viyaFileExtRespLibDs))
|
|
62
|
+
,msg=%str(No <libname.>dataset name provided to cache inital response.)
|
|
63
|
+
,mac=MV_GETVIYAFILEEXTPARMS
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
/* Declare requested parameters as global macro vars and initialize blank */
|
|
67
|
+
%if not %mf_isBlank(&typeDefNameVar) %then %do;
|
|
68
|
+
%global &typeDefNameVar;
|
|
69
|
+
%let &typeDefNameVar = %str();
|
|
70
|
+
%end;
|
|
71
|
+
%if not %mf_isBlank(&propertiesVar) %then %do;
|
|
72
|
+
%global &propertiesVar;
|
|
73
|
+
%let &propertiesVar = %str();
|
|
74
|
+
%end;
|
|
75
|
+
%if not %mf_isBlank(&mediaTypeVar) %then %do;
|
|
76
|
+
%global &mediaTypeVar;
|
|
77
|
+
%let &mediaTypeVar = %str();
|
|
78
|
+
%end;
|
|
79
|
+
|
|
80
|
+
%let base_uri=%mf_getplatform(VIYARESTAPI);
|
|
81
|
+
%if &mdebug=1 %then %do;
|
|
82
|
+
%put DEBUG: &=base_uri;
|
|
83
|
+
%end;
|
|
84
|
+
|
|
85
|
+
%let ext=%lowcase(&ext);
|
|
86
|
+
|
|
87
|
+
/* Create a local copy of the Viya response containing all file type info, if
|
|
88
|
+
it does not already exist. */
|
|
89
|
+
%if not %mf_existds(&viyaFileExtRespLibDs) %then %do;
|
|
90
|
+
/* Create a temp file and fill with JSON that declares */
|
|
91
|
+
/* VIYA file-type details for the given file extension */
|
|
92
|
+
%local viyatypedefs;
|
|
93
|
+
%let viyatypedefs=%mf_getuniquefileref();
|
|
94
|
+
filename &viyatypedefs temp;
|
|
95
|
+
|
|
96
|
+
%let url = &base_uri/types/types?limit=999999;
|
|
97
|
+
|
|
98
|
+
proc http oauth_bearer=sas_services out=&viyatypedefs
|
|
99
|
+
url="&url";
|
|
100
|
+
run;
|
|
101
|
+
|
|
102
|
+
%if &mdebug=1 %then %put DEBUG: &sysmacroname &=url
|
|
103
|
+
&=SYS_PROCHTTP_STATUS_CODE &=SYS_PROCHTTP_STATUS_PHRASE;
|
|
104
|
+
|
|
105
|
+
%if (&SYS_PROCHTTP_STATUS_CODE ne 200) %then %do;
|
|
106
|
+
/* To avoid a breaking change, exit early if the request failed.
|
|
107
|
+
The calling process will proceed with empty requested macro variables. */
|
|
108
|
+
%put INFO: &sysmacroname File extension details were not retrieved.;
|
|
109
|
+
filename &viyatypedefs clear;
|
|
110
|
+
%return;
|
|
111
|
+
%end;
|
|
112
|
+
|
|
113
|
+
%if &mdebug=1 %then %do;
|
|
114
|
+
/* Dump the response to the log */
|
|
115
|
+
data _null_;
|
|
116
|
+
length line $120;
|
|
117
|
+
null=byte(0);
|
|
118
|
+
infile &viyatypedefs dlm=null lrecl=120 recfm=n;
|
|
119
|
+
input line $120.;
|
|
120
|
+
if _n_ = 1 then put "DEBUG:";
|
|
121
|
+
put line;
|
|
122
|
+
run;
|
|
123
|
+
%end;
|
|
124
|
+
|
|
125
|
+
/* Convert the content of that JSON into SAS datasets */
|
|
126
|
+
/* First prepare a new WORK-based folder to receive the datasets */
|
|
127
|
+
%local jsonworkfolder jsonlib opt_dlcreatedir;
|
|
128
|
+
%let jsonworkfolder=%sysfunc(pathname(work))/%mf_getuniquename(prefix=json_);
|
|
129
|
+
%let jsonlib=%mf_getuniquelibref(prefix=json);
|
|
130
|
+
/* And point a libname at it */
|
|
131
|
+
%let opt_dlcreatedir = %sysfunc(getoption(dlcreatedir));
|
|
132
|
+
options dlcreatedir; libname &jsonlib "&jsonworkfolder"; options &opt_dlcreatedir;
|
|
133
|
+
|
|
134
|
+
/* Read the json output once and copy datasets to its work folder */
|
|
135
|
+
%local libref1;
|
|
136
|
+
%let libref1=%mf_getuniquelibref();
|
|
137
|
+
libname &libref1 JSON fileref=&viyatypedefs automap=create;
|
|
138
|
+
proc copy in=&libref1 out=&jsonlib; run;
|
|
139
|
+
|
|
140
|
+
libname &libref1 clear;
|
|
141
|
+
|
|
142
|
+
/* Now give all rows belonging to the same items array a grouping value */
|
|
143
|
+
data &viyaFileExtRespLibDs;
|
|
144
|
+
length _viyaItemIdx 8;
|
|
145
|
+
set &jsonlib..alldata;
|
|
146
|
+
retain _viyaItemIdx 0;
|
|
147
|
+
/* Increment the row group index when a new 'items' group is observed */
|
|
148
|
+
if P=1 and P1='items' then _viyaItemIdx + 1;
|
|
149
|
+
run;
|
|
150
|
+
|
|
151
|
+
%if &mdebug=0 %then %do;
|
|
152
|
+
/* Tidy up, unless debug=1 */
|
|
153
|
+
proc datasets library=&jsonlib nolist kill; quit;
|
|
154
|
+
libname &jsonlib clear;
|
|
155
|
+
%end;
|
|
156
|
+
|
|
157
|
+
filename &viyatypedefs clear;
|
|
158
|
+
|
|
159
|
+
%end; /* If initial filetype query response didn't exist */
|
|
160
|
+
|
|
161
|
+
/* Find the row-group for the current file extension */
|
|
162
|
+
%local itemRowGroup;
|
|
163
|
+
%let itemRowGroup =
|
|
164
|
+
%mf_getValue(
|
|
165
|
+
&viyaFileExtRespLibDs
|
|
166
|
+
,_viyaItemIdx
|
|
167
|
+
,filter=%quote(p1='items' and p2='extensions' and value="&ext")
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
%if &mdebug %then %put DEBUG: &=itemRowGroup;
|
|
171
|
+
|
|
172
|
+
%if %mf_isBlank(&itemRowGroup) %then %do;
|
|
173
|
+
/* extension was not found */
|
|
174
|
+
%if(&mdebug=1) %then %put DEBUG: No type details found for extension "&ext".;
|
|
175
|
+
%return;
|
|
176
|
+
%end;
|
|
177
|
+
|
|
178
|
+
/* Filter the cached response data down to the required file extension */
|
|
179
|
+
%local dsItems;
|
|
180
|
+
%let dsItems = %mf_getuniquename(prefix=dsItems_);
|
|
181
|
+
data work.&dsItems;
|
|
182
|
+
set &viyaFileExtRespLibDs;
|
|
183
|
+
where _viyaItemIdx = &itemRowGroup;
|
|
184
|
+
run;
|
|
185
|
+
|
|
186
|
+
/* Populate typeDefName, if requested */
|
|
187
|
+
%if (not %mf_isBlank(&typeDefNameVar)) %then %do;
|
|
188
|
+
%let &typeDefNameVar = %mf_getvalue(&dsItems,value,filter=%quote(p1="items" and p2="name"));
|
|
189
|
+
%if &mdebug=1 %then %put DEBUG: &=typeDefNameVar &typeDefNameVar=&&&typeDefNameVar;
|
|
190
|
+
%end;
|
|
191
|
+
|
|
192
|
+
/* Populate mediaType, if requested */
|
|
193
|
+
%if (not %mf_isBlank(&mediaTypeVar)) %then %do;
|
|
194
|
+
%let &mediaTypeVar = %mf_getvalue(&dsItems,value,filter=%quote(p1="items" and p2="mediaType"));
|
|
195
|
+
%if &mdebug=1 %then %put DEBUG: &=mediaTypeVar &mediaTypeVar=&&&mediaTypeVar;
|
|
196
|
+
%end;
|
|
197
|
+
|
|
198
|
+
/* Populate properties macro variable, if requested */
|
|
199
|
+
%if not %mf_isBlank(&propertiesVar) %then %do;
|
|
200
|
+
|
|
201
|
+
/* Filter dsItems down to the properties */
|
|
202
|
+
%local dsProperties;
|
|
203
|
+
%let dsProperties = %mf_getuniquename(prefix=dsProperties_);
|
|
204
|
+
data work.&dsProperties ( rename=(p3 = propertyName) );
|
|
205
|
+
set work.&dsItems;
|
|
206
|
+
where p2="properties" and v=1;
|
|
207
|
+
run;
|
|
208
|
+
|
|
209
|
+
/* Check for 1+ properties */
|
|
210
|
+
%if ( %mf_nobs(&dsProperties) = 0 ) %then %do;
|
|
211
|
+
%let &propertiesVar = %str();
|
|
212
|
+
%if &mdebug=1 %then %put DEBUG: &SYSMACRONAME - No Viya properties found for file suffix %str(%')&ext%str(%');
|
|
213
|
+
%end;
|
|
214
|
+
%else %do;
|
|
215
|
+
/* Properties potentially span multiple rows in the input table */
|
|
216
|
+
data _null_;
|
|
217
|
+
length
|
|
218
|
+
line $32767
|
|
219
|
+
properties $32767
|
|
220
|
+
;
|
|
221
|
+
retain properties;
|
|
222
|
+
set &dsProperties end=last;
|
|
223
|
+
if _n_ = 1 then properties = '{';
|
|
224
|
+
|
|
225
|
+
line = cats(quote(trim(propertyName)),':');
|
|
226
|
+
/* Only strings and bools appear in properties */
|
|
227
|
+
if value not in ("true","false") then value = quote(trim(value));
|
|
228
|
+
line = catx(' ',line,value);
|
|
229
|
+
/* Add a comma separator to all except the last line */
|
|
230
|
+
if not last then line = cats(line,',');
|
|
231
|
+
|
|
232
|
+
/* Add this line to the output value */
|
|
233
|
+
properties = catx(' ',properties,line);
|
|
234
|
+
|
|
235
|
+
if last then do;
|
|
236
|
+
/* Close off the properties object and output to the macro variable */
|
|
237
|
+
properties=catx(' ',properties,'}');
|
|
238
|
+
call symputx("&propertiesVar",properties);
|
|
239
|
+
end;
|
|
240
|
+
run;
|
|
241
|
+
|
|
242
|
+
%if &mdebug=1 %then %put DEBUG: &=propertiesVar &propertiesVar=&&&propertiesVar;
|
|
243
|
+
%end;
|
|
244
|
+
|
|
245
|
+
%end;
|
|
246
|
+
|
|
247
|
+
%mend mv_getViyaFileExtParms;
|