Skip to content

Deleted observations being included with read_sas7bdat #307

@fr4nkly82

Description

@fr4nkly82

Describe the issue

When trying to read in a SAS data set that has had observations removed from it using proc sql, those observations are still being displayed when I bring the file into Python using read_sas7bdat.

To Reproduce

/* Run the following code in SAS v9.4: */
libname temp "H:/temp/";

/* Creating a file with deleted observations...*/
data temp.file_with_deleted_obs;
set sashelp.cars;
run;

/* ...by using PROC SQL "delete from" */
proc sql;
delete from temp.file_with_deleted_obs where make='BMW';
quit;

proc contents data=temp.file_with_deleted_obs;
run;
Image
import pyreadstat as py

df, _ = py.read_sas7bdat('H:/temp/file_with_deleted_obs.sas7bdat')
display(df.shape)
df.query('MAKE=="BMW"').reset_index(drop=True)
Image

Expected behavior

df.query('MAKE=="BMW"').reset_index(drop=True)

should return 0 rows, instead it's returning 20.

Setup Information:

How did you install pyreadstat? pip
Platform (windows, macOS, linux, 32 or 64 bit) Windows
Python Version 3.13.5
Python Distribution (System, plain python, Anaconda) miniconda
Using Virtualenv or condaenv? condaenv

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions