私はPSPP *の解決策を見つけました。これはSPSSでも良いかもしれません。アイデアはシンプルですが、あなたが質問で説明したことを自動化して行います。 SPSSのためのスクリプトファイルを書き込むことによって
スタート(以下は、PSPPのためですが、SPSSと非常に類似しているはず):
GET FILE = 'your_SPSS_file_with_full_path.sav'
save translate
/outfile = 'your_resulted_CSV_file_with_full_path.csv'
/type = CSV
/REPLACE
/FIELDNAMES
/CELLS=LABELS.
書き込みCELLS=VALUES
あなたは数値ではなくlablesをしたい場合。
このファイルを保存します(spss2csv.spsという名前のファイル)。 MATLABで
、書き込み以下:
uiimport(your_resulted_CSV_file_with_full_path.csv)
このツール:
sps_file_name = 'full_path\spss2csv.sps';
% replace the path below with the path for SPSS:
command = ['"C:\Program Files\PSPP\bin\pspp.exe" ' sps_file_name];
system(command)
これは、あなたがxlsread
またはimport toolを使用してMatlabのいずれかにインポートすることができ、.csvファイルを生成します。混合データをインポートし、次回に自動的に実行できるようにスクリプトを生成できます。
- export data to spss:反対方向(SPSSにMatlabの)については
は、Exchangeをファイルにこれらの提出を見てみましょう。
- save4spss。
* PSPPは無料で非常に高速ですので、SPSSでこれを実装できない場合はダウンロードしてください。ここで
あなたがPSPPをインストールする場合は、すべてのMatlabの外に取得せずに、MATLABで使用することができる機能です。
function import_sav(sav_file,labels)
% Opens the import tool for importins a sav file
% 'sav_file' is the name of the SPSS\PSPP file to import
% 'labels' is a logical that if true then the file is imported using the
% labels and not the numeric values. Default is TRUE.
if nargin<2
labels = true;
end
[p,csv_file] = fileparts(sav_file);
if isempty(p), p = cd; end
sps_file = [p '\convert2csv.sps'];
% sav_file = 'C:\Users\Eyal\Dropbox\MATLAB\atid\result.sav';
csv_file = [p '\' csv_file '.csv'];
fid = fopen(sps_file,'w');
fprintf(fid,'GET FILE = ''%s''\n',sav_file);
fprintf(fid,'save translate\n');
fprintf(fid,'\t\t/outfile = ''%s''\n',csv_file);
fprintf(fid,'\t\t/type = CSV\n');
fprintf(fid,'\t\t/REPLACE\n');
fprintf(fid,'\t\t/FIELDNAMES\n');
if labels
fprintf(fid,'\t\t/CELLS=LABELS.\n');
else
fprintf(fid,'\t\t/CELLS=VALUES.\n');
end
fclose(fid);
command = ['"C:\Program Files\PSPP\bin\pspp.exe" ' sps_file];
system(command)
uiimport(csv_file)
end
これは、自動的にそのためのデータインポートツールを開きます.SAV関数を呼び出すときに入力するファイル:import_sav('my_file.sav',1)
。
Matlabは[support ODBC](https://www.mathworks.com/help/database/ug/importing-data-from-databases-into-matlab.html)ですが、OPには[データベースツールボックス]が必要です。 (https://www.mathworks.com/help/database/index.html)を参照してください。また、このオプションがSPSSのコアライセンスで公開されているかどうかはわかりません。 – EBH
私は、このドライバは無料で、おそらくBase製品でライセンスされているData Access Packに含まれていると思います。 – JKP