Loading...
Searching...
No Matches
dc_casload.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Loads a CAS table into memory
4 @details There are three versions of this macro, one per build
5 target. The interface is the same. The macro loads the source table
6 to memory (if not loaded) and promotes it.
7
8 Note that we cannot collect metadata from the APIs (like in
9 mv_castabload) because the server info may be inacessible to
10 the logged in user
11
12 Running SAS code under a system account (like proc util) DOES
13 work, so we just make the assumption that the source file and
14 library matches the libds.
15
16 @param [in] libds library.dataset of the CAS table to load
17 @param [in] mdebug= (0) Set to 1 to enable verbose logging
18
19 <h4> SAS Macros </h4>
20 @li mf_getengine.sas
21 @li mfv_getcaslib.sas
22 @li mp_abort.sas
23
24 @author 4GL Apps Ltd
25 @copyright 4GL Apps Ltd. This code may only be used within Data
26 Controller and may not be re-distributed or re-sold without the
27 express permission of 4GL Apps Ltd.
28**/
29
30%macro dc_casload(libds, mdebug=0);
31 %local lib eng caslib ds _exists;
32
33 %mp_abort(
34 iftrue=(&syscc ne 0),
35 msg=%str(syscc=&syscc on macro entry)
36 )
37
38 %let lib=%scan(&libds,1,.);
39 %let eng=%mf_getengine(&lib);
40 %mp_abort(iftrue= (X&eng.X=XX)
41 ,mac=&_program
42 ,msg=%str(Library &lib is not assigned)
43 )
44
45 %if &eng ne CAS %then %return;
46
47 %let caslib=%mfv_getcaslib(lib=&lib);
48 %let ds=%scan(&libds,2,.);
49 %if &mdebug=1 %then %put _local_;
50 /* ---- existence check ------------------------------------------------- */
51 proc cas;
52 table.tableExists result=r /
53 caslib="&caslib"
54 name="&ds";
55 %if &mdebug=1 %then %do;
56 print r;
57 %end;
58 if r.exists > 0 then call symputx('_exists', '1', 'L');
59 else call symputx('_exists', '0', 'L');
60 quit;
61
62 /* ---- already loaded: skip -------------------------------------------- */
63 %if &_exists=1 %then %do;
64 %put NOTE: Table &caslib..&ds already loaded - skipping;
65 %return;
66 %end;
67
68 proc casutil;
69 load casdata="&ds"
70 incaslib="&caslib"
71 casout="&ds"
72 outcaslib="&caslib"
73 promote;
74 quit;
75
76 %mp_abort(
77 iftrue=(&syscc ne 0),
78 msg=%str(Load failed for &caslib..&ds)
79 )
80
81 %put NOTE: Table &caslib..&ds loaded and promoted;
82
83%mend dc_casload;