Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert .dat + .sps to .sav on command line

I get a lot of datasets that arrive as .dat files with syntax files for converting to SPSS (.sps). I'm an R user, so I need to convert the .dat file into a .sav that R can read.

In the past, I've used PSPP to do this manually. (I can't afford SPSS!) But I'd MUCH prefer a programmatic solution.

I thought pspp-convert would do the trick, but there's something I'm not understanding about how that works in terms of inputting the syntax file:

My files are:

  • data.dat
  • data.sps (which correctly points to data.dat)

I tried

pspp-convert data.sps data.sav

But get

`data.sps' is not a system or portable file. 

Makes sense since the input is supposed to be a portable file. Am I trying to do something beyond the scope of this CLI?

Generally speaking, there MUST be some way to apply an SPS file to a DAT file to get a SAV file (or any other portable file) back, right?

like image 324
Chris Wilson Avatar asked Oct 29 '22 21:10

Chris Wilson


1 Answers

From an SPSS Statistics point of view, a .dat file extension most often means the data is in a fixed ASCII text format. You would need the accompanying codebook to tell you what variables to read and in what formats. The SPSS Statistics command syntax file (.sps) does this for you. But this file is simply the list of SPSS Statistics commands used to read the ASCII data. It is not a data file itself.

Elsewhere you've referenced these files as "portable files". An SPSS Statistics portable file (.por) is a very special case of an ASCII file; structured to be read and written by SPSS Statistics. In any case, if your preferred tool takes an SPSS Statistics portable file (.por), these *.dat files likely aren't it.

Assuming these *.dat files are fixed ASCII text files, you'll need to discern how the information therein is stored and then use a likely tool for reading ASCII text.

like image 110
David_Dwyer Avatar answered Nov 09 '22 09:11

David_Dwyer