Skip to content

Latest commit

 

History

History
272 lines (170 loc) · 8.43 KB

File metadata and controls

272 lines (170 loc) · 8.43 KB

Documentation for the SASPACer package.


SASPACer to create SAS package using excel file


Version information:

  • Package: SASPACer
  • Version: 0.3.6
  • Generated: 2025-10-16T20:25:52
  • Author(s): Ryo Nakaya ([email protected])
  • Maintainer(s): Ryo Nakaya ([email protected])
  • License: MIT
  • File SHA256: F*B97036EAE02CC83013B0FE2AFF63556385D464CEBD8F33D009DAD06621C4C14C for this version
  • Content SHA256: C*E9294BC897EB5817BDED91548767BD7C9FC0AE71A86256DFA080EE9EF7671FCA for this version

The SASPACer package, version: 0.3.6;


SASPACer

SASPACer is a package for easily creating SAS packages.

All you need is to fill package information in the template excel file (you can find it in additional contents).
SASPACer has a macro(%ex2pac()) to convert excel with package information into SAS package folders and files, and generate SAS package using the %generatePackage() macro (the generation is optional but executed by default).

macro(%pac2ex()) can convert package zip file into excel file with package information.

list of macros:

  • %ex2pac()
  • %pac2ex()

References

  1. Bartosz Jablonski, "My First SAS Package - a How To", SGF Proceedings, Paper 1079-2021, https://communities.sas.com/t5/SAS-Global-Forum-Proceedings/My-First-SAS-Package-A-How-To/ta-p/726319 https://communities.sas.com/kntur85557/attachments/kntur85557/proceedings-2021/59/1/Paper_1079-2021.pdf



Required SAS Components:

  • Base SAS Software
  • SAS/access interface to PC files


Package contains additional content, run: %loadPackageAddCnt(SASPACer) to load it or look for the saspacer_AdditionalContent directory in the packages fileref localization (only if additional content was deployed during the installation process).


SAS package generated by SAS Package Framework, version 20250729


The SASPACer package content

The SASPACer package consists of the following content:

  1. %ex2pac() macro

  2. %ex2pac_allname() macro

  3. %ex2pac_allsheet() macro

  4. %ex2pac_set_slash() macro

  5. %pac2ex() macro

  6. %pac2ex_contents() macro

  7. %pac2ex_folder2sheet() macro

  8. License note


%ex2pac() macro

%ex2pac is a macro to convert excel file with package information into SAS package folders and files.

Parameters

  • excel_file (required) : full path for excel file which contains package information

  • package_location (required) : location where package files to be stored. Subfolder named package name will be created under the location.

  • complete_generation (option) : If user want to create only package structure, change complete_generation=N. (default is Y)
    By default, %ex2pac execute %generatePackage() to create .zip and .md.

Excel file to read

Easy to understand the structure. Take a look anyway. In sheets like macros, the %ex2pac uses body information if body column is filled, while refers file in location column if body column is blank. (This is a situation where macros(or other files) were already created somewhere in a file and would like to use it instead of copying contents in body column of the excel.)

Flow of the %ex2pac macro

  1. Create package subfolder in the location. Name of the subfolder will be set as the package name.
  2. Create description.sas
  3. Create license.sas
  4. Create subfolders like 01_formats, 02_functions, etc. in reference to the excel sheet names.
  5. Create sas files based on information described in each excel sheet
  6. Run %generatePackages()

Sample code

%ex2pac(
  excel_file=C:\Temp\template_package.xlsx,
  package_location=C:\Temp\SAS_PACKAGES\packages,
  complete_generation=Y)

Note:

  1. %ex2pac expects the operating system to be either Windows or a non-Windows environment (such as Linux, Unix, etc.). The &SYSSCP macro variable is used to identify the current OS.
  2. Libref named e2p_xls and XLSCHK are used in the macro.
  3. Max length of 32767 bytes is the limit in both cells in excel and reference file(.sas) in location column due to limitations in excel cell max length and max length of SAS variables used in the macro.


%ex2pac_allname() macro

This is internal utility macro used in %ex2pac. (Called in %ex2pac_allsheet macro)

Purpose: To create contents in xxx.sas reading excel sheet.


%ex2pac_allsheet() macro

This is internal utility macro used in %ex2pac.

Purpose: To create sheets.


%ex2pac_set_slash() macro

This is internal utility macro used in %ex2pac.

Purpose: To switch separator character (slash or back slash) based on OS.


%pac2ex() macro

%pac2ex is a macro to convert package zip file into excel file with package information.

Parameters

  • zip_path (required) : full path for package zip file

  • xls_path (required) : full path for excel file to output

  • overwrite (option) : N for not overwriting (default is Y)

  • kill (option) : Y for kill all datasets in PAC2EX library created during %pac2ex (default is N)

Flow of the %pac2ex macro

  1. Scan package ZIP contents
  2. Read each ZIP entry line-by-line into PAC2EX.xxx datasets
  3. Process DESCRIPTION and LICENSE
  4. Process macros/contents calling %pac2ex_contents
  5. Export to Excel sheets calling %pac2ex_folder2sheet

Sample code

%pac2ex(
  zip_path=C:\Temp\packagename.zip,
  xls_path=C:\Temp\package_info.xlsx,
  overwrite=Y,
  kill=Y
)

Note:

Not applicable.



%pac2ex_contents() macro

This is internal utility macro used in %pac2ex.

Purpose: To create datasets by contents.


%pac2ex_folder2sheet() macro

This is internal utility macro used in %pac2ex.

Purpose: To output contents into excel sheet.



License

Copyright (c) [2025] [Ryo Nakaya]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.