Macros for SAS Application Developers
https://github.com/sasjs/core
mp_webin.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Fix the `_WEBIN` variables provided to SAS web services
4  @details When uploading files to SAS Stored Processes or Viya Jobs a number
5  of global macro variables are automatically created - however there are some
6  differences in behaviour both between SAS 9 and Viya, and also between a
7  single file upload and a multi-file upload.
8 
9  This macro "straightens" up the global macro variables to make it easier /
10  simpler to write code that works in both environments and with a variable
11  number of file inputs.
12 
13  After running this macro, the following global variables will *always* exist:
14  @li `_WEBIN_FILE_COUNT`
15  @li `_WEBIN_FILENAME1`
16  @li `_WEBIN_FILEREF1`
17  @li `_WEBIN_NAME1`
18 
19  Usage:
20 
21  %mp_webin()
22 
23  This was created as a macro procedure (over a macro function) as it will also
24  use the filename statement in Viya environments (where `_webin_fileuri` is
25  provided).
26 
27  <h4> SAS Macros </h4>
28  @li mf_getplatform.sas
29  @li mf_getuniquefileref.sas
30 
31 **/
32 
33 %macro mp_webin();
34 
35 /* prepare global variables */
36 %global _webin_file_count
37  _webin_filename _webin_filename1
38  _webin_fileref _webin_fileref1
39  _webin_fileuri _webin_fileuri1
40  _webin_name _webin_name1
41  ;
42 
43 /* create initial versions */
44 %let _webin_file_count=%eval(&_webin_file_count+0);
45 %let _webin_filename1=%sysfunc(coalescec(&_webin_filename1,&_webin_filename));
46 %let _webin_fileref1=%sysfunc(coalescec(&_webin_fileref1,&_webin_fileref));
47 %let _webin_fileuri1=%sysfunc(coalescec(&_webin_fileuri1,&_webin_fileuri));
48 %let _webin_name1=%sysfunc(coalescec(&_webin_name1,&_webin_name));
49 
50 
51 /* If Viya, create temporary fileref(s) */
52 %local i;
53 %if %mf_getplatform()=SASVIYA %then %do i=1 %to &_webin_file_count;
54  %let _webin_fileref&i=%mf_getuniquefileref();
55  filename &&_webin_fileref&i filesrvc "&&_webin_fileuri&i";
56 %end;
57 
58 
59 %mend mp_webin;