haven icon indicating copy to clipboard operation
haven copied to clipboard

dataset with zero observations fails to parse, one observation reads in cleanly

Open ajdamico opened this issue 3 years ago • 1 comments

not sure if haven fails to read datasets with zero observations? these two sas files.zip were created off the same source SAS file, keeping zero and then one record with these data steps:

data x.zero_observations;
   set x.pu2018 (obs=0);
run;
data x.one_observation;
   set x.pu2018 (obs=1);
run;

SAS pops up an error when opening the zero-observation dataset, but then allows the user to examine the column names and labels.. haven doesn't allow them to be read in at all

x <- haven::read_sas("one_observation.sas7bdat")
# works

y <- haven::read_sas("zero_observations.sas7bdat")
# Error: Failed to parse C:/Users/AnthonyD/Desktop/zero_observations.sas7bdat: Invalid file, or file has unsupported features.

thanks!!!

ajdamico avatar Aug 02 '21 14:08 ajdamico

Hey @ajdamico, this is an error coming from ReadStat.

@evanmiller can you please have a look? I've tried the linked zero observations file directly in ReadStat and get the same error.

gorcha avatar Aug 05 '21 02:08 gorcha