无法将缺失值分配给字符串
我正在使用 SPSS 语法编辑器来组合字符串变量。我知道每条记录的一个或零个变量中都会有数据,但两个变量中永远不会有数据。这是我的代码,问题出在第一行:
IF (MISSING(ywFamilyPlayers)=1) AND (MISSING(vywFamilyPlayersBoolean)=1) THEN newString=missing.
IF (MISSING(ywFamilyPlayers)=0) newString=VALUELABEL(ywFamilyPlayers).
IF (MISSING(vywFamilyPlayersBoolean)=0) newString=VALUELABEL(vywFamilyPlayersBoolean).
EXECUTE.
我无法弄清楚当它匹配逻辑条件时如何将系统缺失值分配给字符串变量。在这些条件下,我可以轻松分配无意义的文本(例如“-999”或“”),但在对数据运行测试时,系统不会将其视为真正的缺失值。
你能帮我一下吗?这个逻辑是有效的,但我只是不知道如何分配缺失的值。我尝试了许多排列(例如 $sysmis 和 MISSING),但没有成功。
I am using the SPSS syntax editor to combine string variables. I know that there will be data in one or zero of the variables for each record, but there will never be data in both variables. This is my code, and the problem is with the first line:
IF (MISSING(ywFamilyPlayers)=1) AND (MISSING(vywFamilyPlayersBoolean)=1) THEN newString=missing.
IF (MISSING(ywFamilyPlayers)=0) newString=VALUELABEL(ywFamilyPlayers).
IF (MISSING(vywFamilyPlayersBoolean)=0) newString=VALUELABEL(vywFamilyPlayersBoolean).
EXECUTE.
I cannot figure out how to assign the system missing value to the string variable when it matches the logical conditions. I can easily assign nonsense text (e.g. "-999" or "") under those conditions, but the system won't treat it as a true missing value when running tests on the data.
Can you help me out? The logic works, but I just cannot figure out how to assign the missing value. I've experimented with many permutations (e.g. $sysmis and MISSING) but to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,SPSS 中有两种类型的缺失。值可能是系统缺失或用户缺失。据我所知,系统缺失值仅针对数字变量定义。可以为数字变量和字符串变量定义用户缺失值。
尝试使用
MISSING VALUES
命令将值“-999”(例如)定义为用户缺失。Note that there are two types of missingnes in SPSS. Value can be system-missing or user-missing. As far as I know system-missing values are defined only for numeric variables. User-missing values can be defined both for numeric and string variables.
Try
MISSING VALUES
command to define value "-999" (for example) as user-missing.