>100 Views
January 27, 26
スライド概要
SAS言語を中心として,解析業務担当者・プログラマなのコミュニティを活性化したいです
How to Create SAS packages Ryo Nakaya
What is SAS Packages? • SAS macros, functions, data, etc. are packaged in a unified form using SAS Packages Framework (SPF). https://github.com/yabwon/SAS_PACKAGES • Package can be created and shared like R • SASPAC (SAS Packages Archive) Repository https://github.com/SASPAC SAS packages were developed by Bartosz Jablonski * in 2019 and the number of users has been increasing in recent years *Takeda pharmaceutical, Warsaw University of Technology, yabwon 2
How to Create SAS Packages 1. Loading SPF (Setup) - > next slide(3 lines only! ) 1.5. Create a hex logo with ChatGPT, etc.!! 2. 3. Creating Source Files and Folders for a Package - > To be explained in the following slides Execute the% generatePackage () macro This will result in the creation of a [packagename] .zip file (package file) %generatePackage( filesLocation = C:\your\packages\folder, /* location of the files/folders created above */ ) markdownDoc = 1, /* Create .md file*/ easyArch = 1 /* create archive files of .zip and .md */ There are other parameters related to tests, etc. at the time of package preparation.
SPF Setup filename packages "\Your\Folder\"; filename SPFinit url "https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas"; %include SPFinit; %installPackage(SPFinit) filename packages "\Your\Folder\"; %include packages(SPFinit); Once SPFinit.sas is downloaded to the location of packages using the above% installPackage (SPFinit), the following is OK https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/HelloWorldPackage.md Installation and Loading Examples %installPackage(baseplus) %installPackage(SASPACer, sourcePath = https://github.com/Nakaya-Ryo/SASPACer/raw/main/) %installPackage(RWDExpress(0.0.1), github = Narusawa-T) %loadPackage(baseplus) %loadPackage(SASPACer) 4 %loadPackage () looks like library () in R.
Source file folder for package • Standard Configuration • Sequential number (for order of execution at the time of package creation) • Object type (e.g. macro) at end • Test is the test code at the time of package creation • Only numbers, “_ ” and lower case letters • Any files other than .sas files are ignored (except for addcnt). • Addcnt (Additional contents) will be included in the package • “description.sas ” should be an essential file, and“ license.sas ” should be created (to be explained on a later page) https://github.com/yabwon/SAS_PACKAGES/blob/628641a6cfb6c5cf900283e9db450c7fe0e386e9/SPF/Documentatio n/Paper_1079-2021/My%20First%20SAS%20Package%20-%20a%20How%20To.pdf 5 https://github.com/yabwon/SAS_PACKAGES/blob/main/SPF/Documentation/HelloWorldPackage.md
Source file folder for package • Examples of sas file content in each folder Fill in the package information in this format such as type 6
Source file folder for package • Examples of sas file content in each folder 7 Standard text in the MIT License (if liscense.sas file is not present, the MIT standard text is prepopulated.)
Source file folder for package • Examples of sas file content in each folder Help Information Field File name = Object name (1 file: 1 object) (In principle, the same applies to documents other than libname) 8
Source file folder for package • Examples of sas file content in each folder Help Information Field It is impossible to describe Proc format; and run; (Describe only the contents) Formats does not need to be 1 file: 1 object. Note: A folder structure of format (without s) is possible, but the format folder was historically created earlier and should contain a proc format lib = work. & packageName.format; and run; (Formats is usually more convenient.) 9
Source file folder for package • Examples of sas file content in each folder Help Information Field It is impossible to describe Proc fcmp; and run; (Describe only the contents) Note: A folder structure of function (without s) is possible, but the function folder was historically created earlier and should contain proc fcmp outlib = work. & packageName.fcmp.package; and run; (I usually prefer the functionss folder.) 10 For Functions, 1 file: 1 object is not required.
Source file folder for package • Examples of sas file content in each folder Help Information Field Using mylib1 library defined in 01_libname and fmtNum format defined in 02_formats (so folders are numbered sequentially) 11
Source file folder for package • Examples of sas file content in each folder Help Information Field The file is not loaded unless lazyData = is specified in% loadPackage (). 12
Source file folder for package • Examples of sas file content in each folder Help Information Field Macro plays a leading role in package!! 13
Source file folder for package • Examples of sas file content in each folder Help Information Field If testPackage = Y (default) is selected in% generatePackage (), the test is executed when the package is created. 14
Source file folder for package • Additional Contents(Addcnt) %generateP ackage() What's in Addcnt (Anything Basket) 15 The contents of testPackage.zip (package file). Addcnt will be packaged as is in .zip
Output of %generatePackage () Source folder file (input data to be placed in% generatePackage ()) testPackage.md (Markdown document based on description and help information) Package body (.zip), instructions (.md), archive copy (_version) (Output data from% generatePackage ()) 16 Contents of testPackage.zip (package body)
Options to create SAS packages 1. Manually create source files and folders and run %generatePackage You can copy existing source packages(e.g. Adamski) as a start point 2. 3. 4. Use SASPACer Use SASPACerShiny and run %generatePackage Ask Oba-chan(SAS Package Lady) to cook source files and folders and run %generatePackage how_to_create_example_SAS_package.sas
SASPACer • Package for Creating SAS package in one step (A mechanism that you can generally understand when you look at Sample in Excel) https://github.com/PharmaForest/SASPACer • %ex2pac(), %pac2ex() Output source folder files and package files as input in Excel. There is no need to create a folder or file! %ex2pac( excel_file = \folder\to\excel_file.xlsx, package_location = \folder\for\output, complete_generation = Y )
SASPACerShiny • For SAS Package Creation using Rshiny R package (Shiny application) https://github.com/PharmaForest/SASPACerShiny Set up source folder files in the graphical user interface Download and run %generatePackage() separately %generatePackage( filesLocation = \path\to\source\package\folder, markdownDoc = 1, easyArch = 1)
SAS Package Lady • The aunty who cooks SAS Package interactively https://chatgpt.com/g/g68be12f679a88191866ef1e9b35be3c4-sas-package-lady • Support details • Listens to package information • Can add help information when uploading macro files, etc. • The system outputs the source package (folder and file structure) • They also help me create logos • Requires chatGPT sign-up (free version OK) Your aunt will create the source package, download it, and run %generatePackage() separately. %generatePackage( filesLocation = \path\to\source\package\folder, markdownDoc = 1, easyArch = 1)
Enjoy!!
References • • • • • • • • • • • SAS Packages: The Way to Share (a How To), SAS Global Forum 2020, Bartosz Jablonski https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2020/4725-2020.pdf SASPAC(SAS Packages Repository) https://github.com/SASPAC Modern graph package “SAS plotter,” SAS User Group Conference Japan 2024, Kosuke Tsutsugo https://github.com/SASPAC/sasplotter Integration of SAS GRID environment and SF-36 Health Survey scoring API with SAS Packages, PharmaSUG 2024, Bartosz Jablonski https://pharmasug.org/wp-content/uploads/2024/06/PharmaSUG-2024-SD-262.pdf SASPAC - Introduction of a certain Github archive-, The 10th Osaka SAS Study Group 2024, Ryo Nakaya, https://sites.google.com/view/osakasasbenkyokai/%E7%AC%AC10%E5%9B%9E SASPAC2 - Examination of Real World Data acceleration tool -, The 11th Osaka SAS Study Group 2025, Teruko Narusawa, https://sites.google.com/view/osakasasbenkyokai/%E7%AC%AC11%E5%9B%9E PharmaForest https://github.com/PharmaForest SASPACer https://github.com/Nakaya-Ryo/SASPACer SASPACerShiny https://github.com/Nakaya-Ryo/SASPACerShiny SAS Package Lady https://chatgpt.com/g/g-68be12f679a88191866ef1e9b35be3c4-sas-package-lady RWDExpress https://github.com/Narusawa-T/RWDExpress