Skip to content

Morioka-Yutaka/xattr_kit

Repository files navigation

xattr_kit

xattr_kit is a package to simplify the management of SAS extended attributes
Image

%xattr_set_var

Purpose: Assign an extended attribute to a variable.

Parameters:
  lib       - Library name where the dataset resides (default = WORK)
  ds        - Dataset name
  var       - Variable name to which the extended attribute will be assigned
  xname     - Name of the extended attribute
  xvalue    - Value of the extended attribute

Usage Example:

  %xattr_set_var(ds=a, var=x, xname=xa1, xvalue="xxxx");
  %xattr_set_var(ds=a, var=x, xname=xa2, xvalue=1111);
  %xattr_set_var(ds=a, var=y, xname=ya1, xvalue="yyyy");

%xattr_set_ds

Purpose: Assign an extended attribute to a dataset.

Parameters:
  lib       - Library name where the dataset resides (default = WORK)
  ds        - Dataset name
  xname     - Name of the extended attribute
  xvalue    - Value of the extended attribute

Usage Example:

 %xattr_set_ds(ds=a,  xname=xds_a1, xvalue="ds attr 1");

%list_xattr

Purpose: List of attributes printed and/or logged; results stored in xattrs dataset.

Parameters:
  lib           - (Optional) Library name to filter the results
  ds            - (Optional) Dataset name to filter the results
  cat           - (Optional) Category (VARIABLE or DATASET) to filter
  xattr_name    - (Optional) Specific extended attribute name to filter
  display_ods   - (Y/N) Whether to print the result table using PROC PRINT (default = Y)
  put_log       - (Y/N) Whether to output results to log via PUT statement (default = Y)

Usage Example:

%list_xattr()
Image
Image
Image

%xattr_in

Purpose: Reapply extended attributes listed in the xattrs dataset to datasets/variables.

Parameters:
 ds        - Name of the dataset containing the extended attributes (typically 'xattrs')
Variables required for the read data set are [libname],[ds],[var],[xattr],[xtype],[xvalue]

Usage Example:

%xattr_in(ds=xattrs);
Image
Image

%xattr2macrovar

Purpose: Convert extended attribute values into global macro variables.

Parameters:
 lib              - Library name (default = WORK)
 ds               - Dataset name
 xattr_name       - Specific attribute name to extract (optional)
 macro_name_type  - Naming convention for macro variables. Options:
                   "libname_ds_var_xattr", "ds_var_xattr", "var_xattr", "xattr"
                   Default = "ds_var_xattr"

Output: Creates macro variables in the global symbol table with corresponding values.
Usage Example:

%xattr2macrovar(lib=WORK)
Image

version history

0.1.0(22July2025): Initial version

What is SAS Packages?

The package is built on top of SAS Packages framework(SPF) developed by Bartosz Jablonski. For more information about SAS Packages framework, see SAS_PACKAGES.
You can also find more SAS Packages(SASPACs) in SASPAC.

How to use SAS Packages? (quick start)

1. Set-up SPF(SAS Packages Framework)

Firstly, create directory for your packages and assign a fileref to it.

filename packages "\path\to\your\packages";

Secondly, enable the SAS Packages Framework.
(If you don't have SAS Packages Framework installed, follow the instruction in SPF documentation to install SAS Packages Framework.)

%include packages(SPFinit.sas)

2. Install SAS package

Install SAS package you want to use using %installPackage() in SPFinit.sas.

%installPackage(packagename, sourcePath=\github\path\for\packagename)

(e.g. %installPackage(ABC, sourcePath=https://github.com/XXXXX/ABC/raw/main/))

3. Load SAS package

Load SAS package you want to use using %loadPackage() in SPFinit.sas.

%loadPackage(packagename)

Enjoy😁

About

xattr_kit is a package to simplify the management of SAS extended attributes

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages