将 SPSS 元数据变量标签、值标签、数据类型等导出到自定义文本文件 [英] Export SPSS metadata variable labels, value labels, data types etc. to custom text file

查看:144
本文介绍了将 SPSS 元数据变量标签、值标签、数据类型等导出到自定义文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个很大的 SPSS 文件,它有 5MB,有大约 1400 个变量.我们正在将所有内容迁移到数据库,为了配置表格和表单等,我们需要 SPSS 文件中的元数据,但采用特定的自定义格式.

We have a large SPSS file, it's 5MB and has about 1400 variables. We are in the process of migrating everything to a database, and in order to configure the tables and forms etc. we need the metadata from the SPSS file, but in a specific custom format.

所以如果变量视图是这样的:

So if the variable view is like this:

+--------+------------------+---------+-------+----------+----------------+
| Name   | Label            | Type    | Width | Decimals | Values         |
+--------+------------------+---------+-------+----------+----------------+
| PATID  | Patient Id       | Numeric | 8     | 0        |                |
| DOB    | Date Of Birth    | Date    | 11    | 0        |                |
| SEX    | Sex              | String  | 1     | 0        | {F, Female}... |
| ICFORM | Informed consent | Numeric | 8     | 0        | {0, No}...     |
+--------+------------------+---------+-------+----------+----------------+

我们需要一个自定义格式的元数据文件,如下所示:

We need a metadata file in a custom format, something like this:

FieldName;Description;DataType;Width;Decimals;Choices
PATID;"Patient Id";Int;8;0;""
DOB;"Date Of Birth";Datetime;11;0;""
SEX;"Sex";radio;1;0;"F = Female, M = Male"
ICFORM;"Informed consent";radio;8;0;"0 = No, 1 = Yes"

我们还有几个 SPSS 文件,所以最好我想尽可能使用 SPSS 语法来完成.在 this answer 有人建议使用 OMS 来捕获 dictionary 但我不知道它是如何工作的.当我尝试这个时:

We have a couple of more SPSS files so preferable I would like to do it with a SPSS syntax if possible. In this answer someone suggested using OMS to capture dictionary but I have no clue how that would work. When I try this:

DISPLAY dictionary.
OMS dictionary.

我刚刚收到一个错误:

子命令 OMS.未知关键字或子命令:字典.
该命令的执行停止.

Subcommand OMS. Unknown keyword or subcommand: dictionary.
Execution of this command stops.

推荐答案

OMS 确实是你所需要的,但整个过程会是这样的:

OMS is indeed what you need, but the full process will look like this:

DATASET DECLARE  vars.
OMS   /SELECT TABLES
  /IF COMMANDS=['File Information'] SUBTYPES=['Variable Information']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_ OUTFILE='vars' .
DATASET DECLARE  vals.
OMS  /SELECT TABLES
  /IF COMMANDS=['File Information'] SUBTYPES=['Variable Values']
  /DESTINATION FORMAT=SAV NUMBERED=TableNumber_    OUTFILE='vals' .
display dictionary.
omsend.

您现在将拥有两个包含所有变量的变量定义和值标签的新数据集.

You will now have two new datasets containing variable definitions and value labels for all variables.

这篇关于将 SPSS 元数据变量标签、值标签、数据类型等导出到自定义文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆