Metadata-Version: 2.4
Name: saslite
Version: 0.1.2
Summary: Lightweight local SAS language interpreter
Author: SASLite contributors
License-Expression: MIT
Keywords: sas,sas-language,interpreter,data-step,proc-sql,pandas
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Interpreters
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: lark>=1.2.2
Requires-Dist: pandas>=2.2.0
Requires-Dist: numpy>=1.26.0
Requires-Dist: pyreadstat>=1.2.0
Provides-Extra: excel
Requires-Dist: openpyxl>=3.1.0; extra == "excel"
Provides-Extra: gui
Requires-Dist: flask>=3.0.0; extra == "gui"
Requires-Dist: pywebview>=5.0.0; extra == "gui"
Dynamic: license-file

# SASLite

SASLite is a lightweight local interpreter for a practical subset of the SAS
language, implemented in Python on top of pandas. It is intended for local data
checks, small automation workflows, SAS-like examples, and migration/testing
work where a full SAS runtime is not available.

SASLite is an independent project. It is not affiliated with, endorsed by, or
supported by SAS Institute Inc.

## Status

This project is currently alpha software. It supports a useful subset of SAS
syntax, but it is not a complete SAS replacement. Validate results carefully
before using them for regulated, clinical, financial, or other high-stakes work.

## Installation

```bash
pip install saslite
```

Optional extras:

```bash
pip install "saslite[excel]"
pip install "saslite[gui]"
```

For local development from a checkout:

```bash
pip install -e ".[excel,gui]"
```

## Command Line

Run a SAS program:

```bash
saslite path/to/program.sas
```

Run one statement:

```bash
saslite -e "data demo; x = 1; output; run;"
```

Start the interactive prompt:

```bash
saslite --interactive
```

Use a persistent working directory for local datasets:

```bash
saslite --workdir ./work path/to/program.sas
```

## GUI

Install the GUI extra:

```bash
pip install "saslite[gui]"
```

Start the browser-based GUI:

```bash
saslite-gui
```

This starts a local Flask server at `http://127.0.0.1:5000` and opens it in the
default browser. To keep it from opening a browser tab automatically:

```bash
saslite-gui --no-browser
```

Start the desktop wrapper, powered by pywebview:

```bash
saslite-desktop
```

On Windows, the desktop wrapper may require Microsoft Edge WebView2 Runtime.
The browser-based `saslite-gui` command is the simpler fallback.

## Python API

```python
from saslite import SasInterpreter

sas = SasInterpreter()

result = sas.execute(
    """
    data work.employees;
        input name $ age salary;
        datalines;
    Alice 30 50000
    Bob 25 40000
    ;
    run;

    proc print data=work.employees;
    run;
    """
)

print(result.success)
df = sas.get_dataset("WORK", "EMPLOYEES")
print(df)
```

Create a SASLite dataset from pandas:

```python
import pandas as pd
from saslite import SasInterpreter

sas = SasInterpreter()
source = pd.DataFrame({"id": [1, 2, 3], "value": [10, 20, 30]})
sas.create_dataset("source", source)

sas.execute(
    """
    data work.result;
        set work.source;
        doubled = value * 2;
    run;
    """
)

result = sas.get_dataset("WORK", "RESULT")
```

## Supported Features

SASLite includes support for:

- DATA step basics: `DATA`, `SET`, `INPUT`, `DATALINES`, `INFILE`, `OUTPUT`,
  `KEEP`, `DROP`, `RENAME`, `WHERE`, `IF`, `DO`, `BY`, `FIRST.` and `LAST.`
- PROC SQL basics: `SELECT`, `CREATE TABLE`, joins, grouping, ordering,
  calculated columns, `CASE`, `LIKE`, `BETWEEN`, `IN`, `IS NULL`, and common
  aggregate functions.
- PROC steps including `PRINT`, `SORT`, `CONTENTS`, `MEANS`, `SUMMARY`,
  `FREQ`, `IMPORT`, `EXPORT`, `APPEND`, and `DATASETS`.
- LIBNAME references for local work areas.
- A lightweight macro expander for common macro-variable workflows.
- `%INCLUDE` for composing local SAS programs from multiple files.
- Common SAS-style character, numeric, date/time, missing-value, and utility
  functions.
- CSV import/export through the Python API and PROC IMPORT/EXPORT.

See `DOCS.md` and the `examples/` directory in the source repository for more
complete usage notes.

## Examples

```sas
data work.sales;
    input region $ product $ amount;
    datalines;
East Widget 100
West Gadget 200
East Widget 150
;
run;

proc sql;
    create table work.summary as
    select region, sum(amount) as total_sales
    from work.sales
    group by region
    order by total_sales desc;
quit;
```

Run it with:

```bash
saslite examples/basic_sql.sas
```

## Known Limits

SASLite intentionally implements a subset of SAS. Some advanced or environment
specific SAS features are not supported, including the full macro language,
remote libraries, SAS server integration, complete format/informat coverage,
ODS, graphics, and every PROC available in commercial SAS.

When SASLite cannot parse or execute a program exactly, simplify the program to
the supported subset or use the Python API to prepare input datasets directly.

## Development

Install development dependencies:

```bash
pip install -e ".[excel,gui]"
pip install pytest build twine
```

Run tests:

```bash
python -m pytest -q
```

Build distribution artifacts:

```bash
python -m build
```

Check package metadata:

```bash
python -m twine check dist/*
```

## Publishing

Test the package on TestPyPI before publishing to PyPI:

```bash
python -m build
python -m twine upload --repository testpypi dist/*
```

After verifying installation from TestPyPI, publish the same version to PyPI:

```bash
python -m twine upload dist/*
```

## License

SASLite is distributed under the MIT License. See `LICENSE` for details.
