@sasjs/core 4.61.0 → 4.62.1
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/base/mf_getvalue.sas +27 -8
- package/meta/mm_assigndirectlib.sas +51 -1
- package/package.json +1 -1
package/base/mf_getvalue.sas
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
@file
|
|
3
|
-
@brief Retrieves a value from a dataset.
|
|
4
|
-
|
|
3
|
+
@brief Retrieves a value from a dataset. Returned value is fetched from the
|
|
4
|
+
'fetchobs=' record (row 1 by default), after applying the optional filter.
|
|
5
|
+
|
|
5
6
|
@details Be sure to <code>%quote()</code> your where clause. Example usage:
|
|
6
7
|
|
|
7
8
|
%put %mf_getvalue(sashelp.class,name,filter=%quote(age=15));
|
|
@@ -16,21 +17,39 @@
|
|
|
16
17
|
@param [in] libds dataset to query
|
|
17
18
|
@param [in] variable the variable which contains the value to return.
|
|
18
19
|
@param [in] filter= (1) contents of where clause
|
|
20
|
+
@param [in] fetchobs= (1) observation to fetch. NB: Filter applies first.
|
|
19
21
|
|
|
20
22
|
@version 9.2
|
|
21
23
|
@author Allan Bowe
|
|
22
24
|
**/
|
|
23
25
|
|
|
24
|
-
%macro mf_getvalue(libds,variable,filter=1
|
|
26
|
+
%macro mf_getvalue(libds,variable,filter=1,fetchobs=1
|
|
25
27
|
)/*/STORE SOURCE*/;
|
|
26
|
-
%
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
%local dsid;
|
|
29
|
+
|
|
30
|
+
%let dsid=%sysfunc(open(&libds(where=(&filter))));
|
|
31
|
+
%if (&dsid) %then %do;
|
|
32
|
+
%local rc &variable;
|
|
29
33
|
%syscall set(dsid);
|
|
30
|
-
%let rc = %sysfunc(
|
|
34
|
+
%let rc = %sysfunc(fetchobs(&dsid,&fetchobs));
|
|
35
|
+
%if (&rc ne 0) %then %do;
|
|
36
|
+
%put NOTE: Problem reading obs &fetchobs from &libds..;
|
|
37
|
+
%put %sysfunc(sysmsg());
|
|
38
|
+
/* Coerce an rc value of -1 (read past end of data) to a 4
|
|
39
|
+
that, in SAS condition code terms, represents the sysmsg
|
|
40
|
+
w@rning it generates. */
|
|
41
|
+
%if &rc eq -1 %then %let rc = 4;
|
|
42
|
+
/* And update SYSCC if the &rc value is higher */
|
|
43
|
+
%let syscc = %sysfunc(max(&syscc,&rc));
|
|
44
|
+
%end;
|
|
31
45
|
%let rc = %sysfunc(close(&dsid));
|
|
32
46
|
|
|
33
47
|
%trim(&&&variable)
|
|
34
48
|
|
|
35
49
|
%end;
|
|
36
|
-
%
|
|
50
|
+
%else %do;
|
|
51
|
+
%put %sysfunc(sysmsg());
|
|
52
|
+
%let syscc = %sysfunc(max(&syscc,%sysfunc(sysrc())));
|
|
53
|
+
%end;
|
|
54
|
+
|
|
55
|
+
%mend mf_getvalue;
|
|
@@ -213,7 +213,8 @@ run;
|
|
|
213
213
|
%else %if &engine=ODBC %then %do;
|
|
214
214
|
%&mD.put NOTE: Retrieving ODBC connection details;
|
|
215
215
|
data _null_;
|
|
216
|
-
length connx_uri conprop_uri value datasource up_uri schema domprop_uri
|
|
216
|
+
length connx_uri conprop_uri value datasource up_uri schema domprop_uri
|
|
217
|
+
authdomain $256.;
|
|
217
218
|
call missing (of _all_);
|
|
218
219
|
/* get source connection ID */
|
|
219
220
|
rc=metadata_getnasn("&liburi",'LibraryConnection',1,connx_uri);
|
|
@@ -413,6 +414,55 @@ run;
|
|
|
413
414
|
|
|
414
415
|
libname &libref SQLSVR datasrc=&path schema=&schema user="&user" pass="&pass";
|
|
415
416
|
%end;
|
|
417
|
+
%else %if &engine=SASIOSNF or &engine=SNOW %then %do;
|
|
418
|
+
%&mD.put NOTE: Retrieving SNOW connection details;
|
|
419
|
+
data _null_;
|
|
420
|
+
length connx_uri conprop_uri value server up_uri schema domprop_uri
|
|
421
|
+
authdomain database $256.;
|
|
422
|
+
call missing (of _all_);
|
|
423
|
+
/* get source connection ID */
|
|
424
|
+
rc=metadata_getnasn("&liburi",'LibraryConnection',1,connx_uri);
|
|
425
|
+
/* get connection properties */
|
|
426
|
+
i=0;
|
|
427
|
+
do until (rc2<0);
|
|
428
|
+
i+1;
|
|
429
|
+
rc2=metadata_getnasn(connx_uri,'Properties',i,conprop_uri);
|
|
430
|
+
rc3=metadata_getattr(conprop_uri,'Name',value);
|
|
431
|
+
if value='Connection.DBMS.Property.SERVER.Name.xmlKey.txt' then do;
|
|
432
|
+
rc4=metadata_getattr(conprop_uri,'DefaultValue',server);
|
|
433
|
+
rc2=-1;
|
|
434
|
+
end;
|
|
435
|
+
end;
|
|
436
|
+
|
|
437
|
+
/* get auth domain */
|
|
438
|
+
autrc=metadata_getnasn(connx_uri,"Domain",1,domprop_uri);
|
|
439
|
+
arc=metadata_getattr(domprop_uri,"Name",authdomain);
|
|
440
|
+
if not missing(authdomain) then authdomain=cats('AUTHDOMAIN=',authdomain);
|
|
441
|
+
call symputx('authdomain',authdomain,'l');
|
|
442
|
+
|
|
443
|
+
/* get SCHEMA */
|
|
444
|
+
rc6=metadata_getnasn("&liburi",'UsingPackages',1,up_uri);
|
|
445
|
+
rc7=metadata_getattr(up_uri,'SchemaName',schema);
|
|
446
|
+
&mD.put rc= connx_uri= rc2= conprop_uri= rc3= value= rc4= server=
|
|
447
|
+
rc6= up_uri= rc7= schema=;
|
|
448
|
+
|
|
449
|
+
/* get database value */
|
|
450
|
+
prop='Connection.DBMS.Property.DB.Name.xmlKey.txt';
|
|
451
|
+
rc=metadata_getprop("&liburi",prop,database,"");
|
|
452
|
+
if database^='' then database='database='!!quote(trim(database));
|
|
453
|
+
call symputx('database',database,'l');
|
|
454
|
+
|
|
455
|
+
call symputx('snow_schema',schema,'l');
|
|
456
|
+
call symputx('snow_server',server,'l');
|
|
457
|
+
run;
|
|
458
|
+
|
|
459
|
+
libname &libref SNOW SERVER="&snow_server" SCHEMA=&snow_schema &authdomain
|
|
460
|
+
&database;
|
|
461
|
+
%if %length(&open_passthrough)>0 %then %do;
|
|
462
|
+
proc sql;
|
|
463
|
+
connect using &libref as &open_passthrough;
|
|
464
|
+
%end;
|
|
465
|
+
%end;
|
|
416
466
|
%else %if &engine=TERADATA %then %do;
|
|
417
467
|
%put NOTE: Obtaining &engine library details;
|
|
418
468
|
data _null;
|
package/package.json
CHANGED