@sasjs/core 4.36.0 → 4.37.0
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/mp_dsmeta.sas +99 -0
- package/package.json +1 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file
|
|
3
|
+
@brief Export dataset metadata to a single output table
|
|
4
|
+
@details Exports the dataset attributes and enginehost information, then
|
|
5
|
+
converts the datasets into a single output table in the following format:
|
|
6
|
+
|
|
7
|
+
|ODS_TABLE:$10.|NAME:$100.|VALUE:$1000.|
|
|
8
|
+
|---|---|---|
|
|
9
|
+
|`ATTRIBUTES `|`Data Set Name `|`SASHELP.CLASS `|
|
|
10
|
+
|`ATTRIBUTES `|`Observations `|`19 `|
|
|
11
|
+
|`ATTRIBUTES `|`Member Type `|`DATA `|
|
|
12
|
+
|`ATTRIBUTES `|`Variables `|`5 `|
|
|
13
|
+
|`ATTRIBUTES `|`Engine `|`V9 `|
|
|
14
|
+
|`ATTRIBUTES `|`Indexes `|`0 `|
|
|
15
|
+
|`ATTRIBUTES `|`Created `|`06/08/2020 00:59:14 `|
|
|
16
|
+
|`ATTRIBUTES `|`Observation Length `|`40 `|
|
|
17
|
+
|`ATTRIBUTES `|`Last Modified `|`06/08/2020 00:59:14 `|
|
|
18
|
+
|`ATTRIBUTES `|`Deleted Observations `|`0 `|
|
|
19
|
+
|`ATTRIBUTES `|`Protection `|`. `|
|
|
20
|
+
|`ATTRIBUTES `|`Compressed `|`NO `|
|
|
21
|
+
|`ATTRIBUTES `|`Data Set Type `|`. `|
|
|
22
|
+
|`ATTRIBUTES `|`Sorted `|`NO `|
|
|
23
|
+
|`ATTRIBUTES `|`Label `|`Student Data `|
|
|
24
|
+
|`ATTRIBUTES `|`Data Representation `|`SOLARIS_X86_64, LINUX_X86_64, ALPHA_TRU64, LINUX_IA64 `|
|
|
25
|
+
|`ATTRIBUTES `|`Encoding `|`us-ascii ASCII (ANSI) `|
|
|
26
|
+
|`ENGINEHOST `|`Data Set Page Size `|`65536 `|
|
|
27
|
+
|`ENGINEHOST `|`Number of Data Set Pages `|`1 `|
|
|
28
|
+
|`ENGINEHOST `|`First Data Page `|`1 `|
|
|
29
|
+
|`ENGINEHOST `|`Max Obs per Page `|`1632 `|
|
|
30
|
+
|`ENGINEHOST `|`Obs in First Data Page `|`19 `|
|
|
31
|
+
|`ENGINEHOST `|`Number of Data Set Repairs `|`0 `|
|
|
32
|
+
|`ENGINEHOST `|`Filename `|`/opt/sas/sas9/SASHome/SASFoundation/9.4/sashelp/class.sas7bdat `|
|
|
33
|
+
|`ENGINEHOST `|`Release Created `|`9.0401M7 `|
|
|
34
|
+
|`ENGINEHOST `|`Host Created `|`Linux `|
|
|
35
|
+
|`ENGINEHOST `|`Inode Number `|`28314616 `|
|
|
36
|
+
|`ENGINEHOST `|`Access Permission `|`rw-r--r-- `|
|
|
37
|
+
|`ENGINEHOST `|`Owner Name `|`sas `|
|
|
38
|
+
|`ENGINEHOST `|`File Size `|`128KB `|
|
|
39
|
+
|`ENGINEHOST `|`File Size (bytes) `|`131072 `|
|
|
40
|
+
|
|
41
|
+
Example usage:
|
|
42
|
+
|
|
43
|
+
%mp_dsmeta(work.sashelp,outds=work.mymeta)
|
|
44
|
+
proc print data=work.mymeta;
|
|
45
|
+
run;
|
|
46
|
+
|
|
47
|
+
@param libds The library.dataset to export the metadata for
|
|
48
|
+
@param outds= (work.dsmeta) The output table to contain the metadata
|
|
49
|
+
|
|
50
|
+
<h4> Related Files </h4>
|
|
51
|
+
@li mp_dsmeta.test.sas
|
|
52
|
+
|
|
53
|
+
**/
|
|
54
|
+
|
|
55
|
+
%macro mp_dsmeta(libds,outds=work.dsmeta);
|
|
56
|
+
|
|
57
|
+
%local ds1 ds2;
|
|
58
|
+
data;run; %let ds1=&syslast;
|
|
59
|
+
data;run; %let ds2=&syslast;
|
|
60
|
+
|
|
61
|
+
/* setup the ODS capture */
|
|
62
|
+
ods output attributes=&ds1 enginehost=&ds2;
|
|
63
|
+
|
|
64
|
+
/* export the metadata */
|
|
65
|
+
proc contents data=&libds;
|
|
66
|
+
run;
|
|
67
|
+
|
|
68
|
+
/* load it into a single table */
|
|
69
|
+
data &outds (keep=ods_table name value);
|
|
70
|
+
length ods_table $10 name label2 label1 label $100
|
|
71
|
+
value cvalue cvalue1 cvalue2 $1000
|
|
72
|
+
nvalue nvalue1 nvalue2 8;
|
|
73
|
+
if _n_=1 then call missing (of _all_);
|
|
74
|
+
* putlog (_all_)(=);
|
|
75
|
+
set &ds1 (in=atrs) &ds2 (in=eng);
|
|
76
|
+
if atrs then do;
|
|
77
|
+
ods_table='ATTRIBUTES';
|
|
78
|
+
name=coalescec(label1,label);
|
|
79
|
+
value=coalescec(cvalue1,cvalue,put(coalesce(nvalue1,nvalue),best.));
|
|
80
|
+
output;
|
|
81
|
+
if label2 ne '' then do;
|
|
82
|
+
name=label2;
|
|
83
|
+
value=coalescec(cvalue2,put(nvalue2,best.));
|
|
84
|
+
output;
|
|
85
|
+
end;
|
|
86
|
+
end;
|
|
87
|
+
else if eng then do;
|
|
88
|
+
ods_table='ENGINEHOST';
|
|
89
|
+
name=coalescec(label1,label);
|
|
90
|
+
value=coalescec(cvalue1,cvalue,put(coalesce(nvalue1,nvalue),best.));
|
|
91
|
+
output;
|
|
92
|
+
end;
|
|
93
|
+
run;
|
|
94
|
+
|
|
95
|
+
proc sql;
|
|
96
|
+
drop table &ds1, &ds2;
|
|
97
|
+
|
|
98
|
+
%mend mp_dsmeta;
|
|
99
|
+
|
package/package.json
CHANGED