PHP code example of sakalauskas / spss

1. Go to this page and download the library: Download sakalauskas/spss library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sakalauskas / spss example snippets


$reader = \SPSS\Reader::fromFile('path/to/file.sav');

$reader = \SPSS\Reader::fromString(file_get_contents('path/to/file.sav'));

$writer = new \SPSS\Writer([
    'header' => [
            'prodName'     => '@(#) SPSS DATA FILE test',
            'layoutCode'   => 2,
            'compression'  => 1,
            'weightIndex'  => 0,
            'bias'         => 100,
            'creationDate' => '13 Feb 89',
            'creationTime' => '13:13:13',
    ],
    'variables' => [
        [
                'name'     => 'VAR1',
                'width'    => 0,
                'decimals' => 0,
                'format'   => 5,
                'columns'  => 50,
                'align'    => 1,
                'measure'  => 1,
                'data'     => [
                    1, 2, 3
                ],
        ],
        ...
    ]
]);