Package: ksformat 0.8.5

Vladimir Larchenko

ksformat: 'SAS'-Style 'PROC FORMAT' for R

Provides 'SAS' 'PROC FORMAT'-like functionality for creating and applying value formats in R. Supports discrete and range-based mapping of values to labels, reverse formatting (invalue), date/time/datetime formatting with built-in 'SAS' format names, multi-label formats, expression labels evaluated at apply-time, case-insensitive matching, import/export of format definitions, and proper handling of missing values (NA, NULL, NaN).

Authors:Vladimir Larchenko [aut, cre], Igor Aleschenkov [aut]

ksformat_0.8.5.tar.gz
ksformat_0.8.5.zip(r-4.7-any)ksformat_0.8.5.zip(r-4.6-any)ksformat_0.8.5.zip(r-4.5-any)
ksformat_0.8.5.tgz(r-4.6-any)ksformat_0.8.5.tgz(r-4.5-any)
ksformat_0.8.5.tar.gz(r-4.7-any)ksformat_0.8.5.tar.gz(r-4.6-any)
ksformat_0.8.5.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
ksformat/json (API)

# Install 'ksformat' in R:
install.packages('ksformat', repos = c('https://crow16384.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/crow16384/ksformat/issues

Pkgdown/docs site:https://crow16384.github.io

On CRAN:

Conda:

datasetdplyrformatr-projecttidytidyversequarto

5.62 score 10 scripts 276 downloads 31 exports 1 dependencies

Last updated from:ce9ea0599f. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK122
source / vignettesOK177
linux-releaseOK111
macos-releaseOK153
macos-oldrelOK130
windows-develOK135
windows-releaseOK136
windows-oldrelOK123
wasm-releaseOK96

Exports:efclearfexportfimportfinputfinputcfinputkfinputnflevelsflistfmapfmap_rangesfmap_stratafmap_to_rangesfnewfnew_bidfnew_dateformat_getformat_library_appfparsefprintfputfput_allfput_dffputcfputkfputnfrangesis_missingksformat_cheatsheetrange_spec

Dependencies:cli

ksformat Usage Examples
Example 1: Basic Discrete Formatting | Example 2: Numeric Range Formatting | Example 3: Decimal Ranges (BMI Categories) | Example 4: Exclusive/Inclusive Bounds | Example 5: Reverse Formatting with Invalue | Example 6: Bidirectional Formatting | Example 7: Parse Multiple Formats from Text | Example 8: Export Formats Back to Text | Example 9: SAS-like PUT/INPUT Functions | Example 10: Data Frame Formatting | Example 11: Missing Value Handling | Example 12: Date/Time Formats (SAS-style) | SAS Date Formats | R Numeric Dates (Days Since 1970-01-01) | Time Formats | Datetime Formats | Custom Date Formats with fnew_date() | Date Formats in Data Frames | Parse Date Formats from Text | Example 13: Multilabel Formats | Overlapping Age Categories | Multilabel with Missing Values | Parse Multilabel from Text | Multilabel Export | Practical Example: Adverse Event Severity Grading | Example 14: Case-Insensitive Matching | Example 15: Expression Labels in Formats | Simple sprintf Expression | Two Extra Arguments (.x1, .x2) | ifelse Expression | Mixed Static and Expression Labels | Expression in .other Fallback | Scalar Recycling | Statistical Table Format with Computed Labels | Example 16: Vectorized Format Names (SAS PUTC-style) | Example 17: Working with Dates and Formats — PUTN | Example 18: Import SAS Formats from CNTLOUT CSV | Use Imported Formats | Apply to Data Frame | Export Imported Format | Selective Import (No Auto-register) | Example 19: Bilingual Format | Example 20: Composite Key Lookup with fputk() | Character lookup (returns character strings) | Native Date lookup (returns Date objects) | Example 21: Consistent Data-Driven Formats with fmap() | Clinical-data example | Same fmap(keys, values) pattern for both types | When to use the default (reversal on) | Summary | Example 22: Date Lookup via fparse() and fputk() | Character date lookup | Native Date lookup | Round-trip: export and re-import | Example 23: Inspecting Range Rules with franges() | Completing a Summary Against Format Labels | Getting Unique Labels from a Format | Example 24: Reverse Range Lookup with fmap_to_ranges() | Example 25: Date Range Bucketing | Fiscal-year bucketing | Define from text with fparse() | LOW / HIGH open-ended bounds | Export and roundtrip | Overlapping buckets with multilabel and fput_all() | Auto-detection of type | Datetime range bucketing | Example 26: Stratified Range Lookup with fputk() | Programmatic construction with fmap_strata() | Text definition with fparse() | Date subtype: per-subject windows | Roundtrip via fexport() / fparse() | Example 27: Plain Range Lookup with fmap_ranges() | Example 28: Composite Key Lookup with NA Components (na_as_string) | Clinical example — LB parameter derivation | The rule of thumb | Example 29: Composite Label Invalue Lookup with finputk() | Basic usage | With NA components (na_as_string = TRUE) | Example 30: Extract Discrete Levels with flevels() | Example 31: Numeric Pattern Formatting | Example 32: Bidirectional nocase for Character Types

Last update: 2026-10-03
Started: 2026-02-18

Non-standard Applications of ksformat for Clinical Trials and Other Tasks
Overview | 1. Protocol windows and subject-specific buckets | 2. Composite keys for clinical mappings | 3. Reverse lookup for QC and cleaning | 4. Report-ready numeric formatting | 5. Bucketing dates into operational periods | 6. Text generation for listings and narratives | 7. Practical cautions | 8. fparse() syntax for all format families | VALUE blocks for discrete lookup | INVALUE blocks for reverse lookup | Date, time, and datetime patterns | Numeric display patterns | Range formats | Stratified range formats | When to use fnew() anyway | Conclusion

Last update: 2026-10-03
Started: 2026-07-09

Readme and manuals

Help Manual

Help pageTopics
ksformat: 'SAS'-Style 'PROC FORMAT' for Rksformat-package ksformat
Mark a Label for Expression Evaluatione
Remove Format(s) from Libraryfclear
Export Formats to 'SAS'-like Textfexport
Import Formats from 'SAS' PROC FORMAT CNTLOUT CSVfimport
Create Invalue Format (Reverse Formatting like 'SAS' INVALUE)finput
Apply Character Invalue by Name (like 'SAS' INPUTC)finputc
Apply Invalue Using a Composite Labelfinputk
Apply Numeric Invalue by Name (like 'SAS' INPUTN)finputn
Extract Value/Label Levels from a Formatflevels
List Format Names from Libraryflist
Create a Key-Value Mapping for Format Creationfmap
Build a Vector of Range Mappingsfmap_ranges
Build a Vector of Stratified Range Mappingsfmap_strata
Reverse-Lookup Range Bounds from Labelsfmap_to_ranges
Create a Format Definition (like 'SAS' PROC FORMAT)fnew
Create Bidirectional Formatfnew_bid
Create Date/Time Formatfnew_date
Retrieve a Format from the Libraryformat_get
Launch Shiny Browser for Format Libraryformat_library_app
Parse Format Definitions from 'SAS'-like Textfparse
Print Format(s) from Libraryfprint
Apply Format to Data (like 'SAS' PUT function)fput
Apply Format and Return All Matches (Multilabel)fput_all
Apply Format to Data Frame Columnsfput_df
Apply Character Format by Name (like 'SAS' PUTC)fputc
Apply Format Using a Composite Keyfputk
Apply Numeric Format by Name (like 'SAS' PUTN)fputn
Extract Range Entries from a Formatfranges
Check if Value is Missingis_missing
Open the ksformat cheat sheetksformat_cheatsheet
Print Format Objectprint.ks_format
Print Invalue Objectprint.ks_invalue
Create Range Specificationrange_spec