The main script creates data internally via `datalines4`. The `%mm_getdetails` macro interacts with the SAS metadata server to retrieve system information (metadata). The `%macro_without_brief_tag` macro operates on internally passed arguments and does not process external data.
1 Code Block
DATA STEP Data
Explanation : This DATA Step block creates the `work.Location` dataset. It defines variable attributes (length, format, label) and reads the data provided in the `datalines4` section. `datalines4` allows integrating data directly into the script, formatted as CSV with a comma delimiter. The `DATETIME22.3` format indicates that the date is stored as a SAS numeric value, representing the date and time with millisecond precision.
Explanation : `PROC APPEND` is used to append all observations from the `work.Location` dataset (previously created) to the end of the `productn.Location` dataset. This procedure is efficient for adding new rows to an existing table without having to recreate it entirely. The `productn.Location` table is assumed to exist or be created by another process.
Explanation : This block defines the SAS macro `%macro_without_brief_tag`. It takes an argument `i_desc` and displays it directly in the SAS log via `%PUT`. This simple macro is primarily intended for testing, debugging, or displaying the value of a macro variable.
Explanation : This macro, `%mm_getdetails`, is designed to extract detailed information (attributes and associations) from a SAS metadata object URI. It takes a URI as input and two optional output datasets (`outattrs` and `outassocs`). The first DATA Step block iterates through the associations of the specified URI using the `metadata_getnasl` and `metadata_getnasn` functions, then extracts names via `metadata_getattr`, storing this information in `&outassocs`. The second DATA Step block extracts properties and attributes of the URI using `metadata_getnprp` and `metadata_getnatr`, storing the details in `&outattrs`. Each dataset is then sorted by `PROC SORT` according to the provided options.
Copied!
%macro mm_getdetails(uri
,outattrs=work.attributes
,outassocs=work.associations
,sortoptions=
)/*/STORE SOURCE*/;
data &outassocs;
keep assoc assocuri name;
length assoc assocuri name $256;
call missing(of _all_);
rc1=1;n1=1;
do while(rc1>0);
/* Walk through all possible associations of this object. */
rc1=metadata_getnasl("&uri",n1,assoc);
rc2=1;n2=1;
do while(rc2>0);
/* Walk through all the associations on this machine object. */
rc2=metadata_getnasn("&uri",trim(assoc),n2,assocuri);
if (rc2>0) then do;
rc3=metadata_getattr(assocuri,"Name",name);
output;
end;
call missing(name,assocuri);
n2+1;
end;
n1+1;
end;
run;
proc sort &sortoptions;
by assoc name;
run;
data &outattrs;
keep type name value;
length type $4 name $256 value $32767;
rc1=1;n1=1;type='Prop';name='';value='';
do while(rc1>0);
rc1=metadata_getnprp("&uri",n1,name,value);
if rc1>0 then output;
n1+1;
end;
rc1=1;n1=1;type='Attr';
do while(rc1>0);
rc1=metadata_getnatr("&uri",n1,name,value);
if rc1>0 then output;
n1+1;
end;
run;
proc sort &sortoptions;
by type name;
run;
%mend mm_getdetails;
1
%macro mm_getdetails(uri
2
,outattrs=work.attributes
3
,outassocs=work.associations
4
,sortoptions=
5
)/*/STORE SOURCE*/;
6
7
DATA &outassocs;
8
keep assoc assocuri name;
9
LENGTH assoc assocuri name $256;
10
call missing(of _all_);
11
rc1=1;n1=1;
12
DO while(rc1>0);
13
/* Walk through all possible associations of this object. */
14
rc1=metadata_getnasl("&uri",n1,assoc);
15
rc2=1;n2=1;
16
DO while(rc2>0);
17
/* Walk through all the associations on this machine object. */
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de. This file is part of SASUnit, the unit testing framework for SAS(R) programs. For copyright information and terms of use under the GNU Lesser General Public License, see the included README.md file or https://github.com/HMS-Analytical-Software/SASUnit/wiki/readme/.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.