READSTAT(1)

✨ READSTAT(1) β€” the readstat glow-up ✨

okay bestie, gather round, because this is the manual page for readstat, from the General Commands Manual section of the Unix world. she reads and writes data set files from SAS, SPSS and Stata, and honestly? she's serving range. πŸ’…


🌸 NAME 🌸

readstat β€” read and write data set files from SAS, SPSS, and Stata πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

three whole invocation styles, we love a flexible queen:

readstat input-file
readstat [-f] input-file output-file
readstat [-f] input-file metadata-file output-file

πŸ’– DESCRIPTION πŸ’–

so basically, readstat converts data set files from the popular statistics packages, and it handles both plain-text and binary formats. no cap. 🌈

✨ style one: just peeking ✨

in the first invocation style, readstat shows you the metadata from input-file β€” the row count, column count, text encoding, and timestamp. vibe check on the file, basically.

input-file should be a file with one of these extensions, and each one is its own little icon:

  • sas7bdat β€” SAS binary file, created with SAS version 7 or newer πŸ”₯
  • xpt β€” SAS portable file, version 5 or version 8, created with the SAS XPORT command
  • sav β€” SPSS uncompressed binary file
  • zsav β€” SPSS compressed binary file (compressed but make it fashion)
  • por β€” SPSS portable file
  • dta β€” Stata binary file, version 104 or newer πŸ‘‘

and okay, important lore: if the row count can't be determined from the file header β€” which is sometimes the case with SPSS binary files and always the case with SPSS portable files β€” then readstat will report a value of -1. that's not a bug bestie, that's just the truth. 😭

🌟 style two: the transformation 🌟

in the second invocation style, readstat converts input-file into output-file β€” like turning a SAS portable file into a Stata binary file, which is giving glow-up montage energy.

on top of the extension list from before, output-file can also have the extension csv or xlsx, which creates a CSV or Excel file respectively. options on options on options. πŸ’…

🧚 style three: the extra-metadata era 🧚

the third invocation style is the one you reach for when extra metadata about the input file β€” like value labels or column widths β€” lives in a separate file. several types of metadata file are supported:

  • sas7bcat β€” SAS binary "catalog" file, created with SAS version 7 or newer, containing value labels
  • json β€” JavaScript Object Notation (JSON) file, containing column metadata that cannot be gleaned from the input CSV. for the details, go read the manual page for the extract_metadata command πŸ“–
  • dct β€” Stata dictionary file, containing the data layout and column metadata for a plain-text input file
  • sps β€” SPSS command file, describing the data layout and column metadata for a plain-text input file
  • sps β€” SAS command file, describing the data layout and column metadata for a plain-text input file
ok not me noticing the page lists sps twice β€” once for SPSS and once for SAS. I'm just the messenger bestie, I promise I'm not the one who did that. πŸ’€

the last three formats can be used for both fixed-width and delimiter-separated (e.g. tab-separated) input files. these are commonly distributed along with plain-text ASCII data sets. iconic behavior honestly. πŸ“

both input and output formats are implied by the file extension. she reads the extension, she knows what to do. main character energy. ⭐


πŸ’… OPTIONS πŸ’…

  • -f β€” overwrite any existing output-file. yes she will simply replace it. no hesitation.

πŸ’€ BUGS πŸ’€

ok so we have to be real for a sec, because there are two things:

  • SAS binary files created by readstat do not open with current versions of SAS. 😭
  • the finer details of format strings (e.g. "%8.2g") are not properly converted between file formats.
ngl these are the "we know, we're working on it" corner of the page. don't say nobody warned you. πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Copyright (C) 2012-2019 Evan Miller, and others where indicated. 🫢


and that's the whole page, bestie β€” this one is from the General Commands Manual, dated 23 January 2019, and it's the READSTAT(1) page. go forth and convert some data sets. periodt. βœ¨πŸŽ€πŸ¦‹