StatLang VS Code Extension
Statistical scripting language syntax highlighting and execution support for VS Code
Features
- Syntax Highlighting: Statistical scripting language syntax highlighting for
.statlang files
- Code Snippets: Common statistical analysis patterns and procedures
- File Execution: Run StatLang files directly from VS Code
- Notebook Support: Interactive statistical notebooks (both
.ipynb with StatLang kernel and .stlnb files)
- IntelliSense: Code completion and syntax checking
- Integrated Terminal: View results in VS Code's integrated terminal
Installation
- Install the extension from the VS Code Marketplace
- Install the StatLang Python package:
pip install statlang
This will automatically install all dependencies including Jupyter kernel support.
- Install the Jupyter kernel for notebook support:
python -m statlang.kernel install
Usage
Basic StatLang Files (.statlang)
- Create a new file with
.statlang extension
- Write your StatLang code
- Use
Ctrl+Shift+P → "StatLang: Run File" to execute
- View results in the integrated terminal
Interactive Notebooks
Option 1: Standard Jupyter Notebooks (.ipynb)
- Install the StatLang kernel:
python -m statlang.kernel install
- Create a new Jupyter notebook (
.ipynb)
- Select "statlang" as the kernel
- Write StatLang code in cells and execute
Option 2: StatLang Notebooks (.stlnb)
- Create a new file with
.stlnb extension
- Write StatLang code in cells
- Execute cells individually or run all
- View formatted output and datasets
Code Snippets
Type common statistical analysis patterns and press Tab to expand:
data → DATA step template
proc → Statistical procedure template
means → PROC MEANS template
freq → PROC FREQ template
reg → PROC REG template
sql → PROC SQL template
macro → Macro definition template
Supported Features
- DATA Steps: Variable creation, conditional logic, DATALINES
- PROC MEANS: Descriptive statistics with CLASS variables and OUTPUT statements
- PROC FREQ: Frequency tables and cross-tabulations with options
- PROC SORT: Data sorting with ascending/descending order
- PROC PRINT: Data display and formatting
- PROC REG: Linear regression analysis with MODEL, OUTPUT, and SCORE statements
- PROC SURVEYSELECT: Random sampling with SRS method, SAMPRATE/N options, and OUTALL flag
- PROC UNIVARIATE: Detailed univariate analysis with distribution diagnostics
- PROC CORR: Correlation analysis (Pearson, Spearman)
- PROC FACTOR: Principal component analysis and factor analysis
- PROC CLUSTER: Clustering methods (k-means, hierarchical)
- PROC NPAR1WAY: Nonparametric tests (Mann-Whitney, Kruskal-Wallis)
- PROC TTEST: T-tests (independent and paired)
- PROC LOGIT: Logistic regression modeling
- PROC TIMESERIES: Time series analysis and seasonal decomposition
- PROC TREE/FOREST/BOOST: Machine learning (decision trees, random forests, gradient boosting)
- PROC SQL: SQL query processing with DuckDB backend
- PROC LANGUAGE: Built-in LLM integration for text generation and analysis
- SAS Macro System: %MACRO/%MEND, %LET, & substitution, %PUT, %IF/%THEN/%ELSE, %DO/%END
- SAS Format System: Built-in date/time, numeric, and currency formats with metadata persistence
- Macro Variables: %LET, %PUT statements
- Libraries: LIBNAME functionality
- TITLE Statements: Title support for output formatting
Configuration
The extension can be configured through VS Code settings:
statlang.pythonPath: Path to Python executable
statlang.runtimePath: Path to StatLang runner script
statlang.showOutputOnRun: Show output channel when running code
Requirements
- Python 3.8 or higher
- StatLang Python package
- VS Code 1.60.0 or higher
Demo
Check out the comprehensive demo in examples/statlang_walkthrough.ipynb to see all features in action.
Contributing
Contributions are welcome! Please see the main project repository for contribution guidelines.
License
MIT License - see LICENSE for details.
Support
⚖️ Legal Disclaimer
This extension uses original, independently developed code to implement a statistical scripting language for educational and analytical use.
StatLang is provided as-is, under an open-source license, for research and community contribution purposes.