@sasjs/core 4.62.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.
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  @file
3
- @brief Retrieves a value from a dataset. If no filter supplied, then first
4
- record is used.
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
- %if %mf_getattrn(&libds,NLOBS)>0 %then %do;
27
- %local dsid rc &variable;
28
- %let dsid=%sysfunc(open(&libds(where=(&filter))));
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(fetch(&dsid));
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
- %mend mf_getvalue;
50
+ %else %do;
51
+ %put %sysfunc(sysmsg());
52
+ %let syscc = %sysfunc(max(&syscc,%sysfunc(sysrc())));
53
+ %end;
54
+
55
+ %mend mf_getvalue;
package/package.json CHANGED
@@ -32,5 +32,5 @@
32
32
  "lint": "npx @sasjs/cli lint",
33
33
  "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
34
34
  },
35
- "version": "4.62.0"
35
+ "version": "4.62.1"
36
36
  }