资源简介
SPSS编程,主要介绍spss编程方面的内容

代码片段和文件信息
# Find all variables in the current dataset that do not have any value labels.
# This illustrates the use of the spss.CreateXPathDictionary api which produces the entire dictionary
# and the Python xml processing facilities.
# An alternative way of processing the dictionary information is using XPath via the spss.EvaluateXPath api.
# This module is for use with the 3rd Edition of SPSS Programming and Data Management.
# To make use of this module copy it to your Python “site-packages“ directory which is typically
# C:\Python24\Lib\site-packages. This module makes use of the spss module which is available once you‘ve
# installed the SPSS-Python Integration Plug-In.
#pubsmarker:import_start
from xml.sax.handler import ContentHandler
import xml.sax
import random codecs locale
import spss
#pubsmarker:import_end
# This class extracts the list of variables from the variable dictionary and determines which ones have
# value labels by using the xml.sax module.
# The StartElement method of the content handler sees every element in the variable dictionary.
# It selects only variable name and value label information and updates the sets as they appear.
# These are later retrieved from the handler object.
# It may be helpful in working through this example to look at actual dictionary xml. You can
# produce a file of this using something like
# spss.GetxmlUtf16(tag filespec)
# where tag identifies the output of spss.CreateXPathDictionary in the xml workspace.
__author__ = ‘spss‘
__version__= ‘1.0.0‘
# History
# 22-Mar-2006 Initial version
#pubsmarker:labelhandler_start
class valueLabelHandler(ContentHandler):
“““Create two sets: one listing all variable names and
the other listing variables with value labels“““
def __init__(self):
self.varset = set()
self.vallabelset = set()
def startElement(self name attr):
if name == u“variable“:
self.varset.add(attr.getValue(u“name“))
elif name == u“valueLabelVariable“:
self.vallabelset.add(attr.getValue(u“name“))
#pubsmarker:labelhandler_end
# Use the class above to find variables without value labels
#pubsmarker:varsnolabels_start
def FindVarsWithoutValueLabels():
handler = valueLabelHandler()
tag = “D“+ str(random.uniform(01))
spss.CreateXPathDictionary(tag)
# Retrieve and parse the variable dictionary
xml.sax.parseString(spss.GetxmlUtf16(tag)handler)
spss.DeleteXPathHandle(tag)
# Print a list of variables in varset that aren‘t in vallabelset
# Convert from Unicode to the current character set
nolabelset = handler.varset.difference(handler.vallabelset)
encoding = locale.getlocale()[1]
if nolabelset:
print “The following variables have no value labels:“
print “\n“.join([codecs.encode(vencoding) for v in nolabelset])
else:
print “All variables in this dataset have at least one value label.“
#pubsmarker:varsnolabels_end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 216 2004-05-07 08:23 examples\commands\access1.sps
文件 308 2004-05-07 08:24 examples\commands\access2.sps
文件 311 2004-05-07 08:24 examples\commands\access_multtables1.sps
文件 190 2004-05-07 08:24 examples\commands\add_files1.sps
文件 599 2006-02-15 11:17 examples\commands\add_files2.sps
文件 410 2004-05-11 12:30 examples\commands\aggregate1.sps
文件 343 2004-05-11 12:30 examples\commands\aggregate2.sps
文件 710 2006-01-12 14:48 examples\commands\append_to_table.sps
文件 693 2004-05-07 08:26 examples\commands\apply_properties.sps
文件 215 2004-05-07 08:26 examples\commands\asynchro_example1.SPS
文件 176 2004-05-07 08:26 examples\commands\asynchro_example1a.sps
文件 293 2004-05-07 08:26 examples\commands\casestovars.sps
文件 2548 2004-05-07 08:26 examples\commands\Challenge_Find_Variables_With_Missing_Labels.SPS
文件 662 2004-05-07 08:27 examples\commands\check.sps
文件 286 2006-01-16 17:26 examples\commands\concat_string.sps
文件 623 2004-05-07 08:27 examples\commands\conditional_include.sps
文件 619 2004-08-05 14:18 examples\commands\conditional_insert.sps
文件 297 2006-01-05 12:07 examples\commands\dataset_subsets.sps
文件 505 2006-01-11 16:59 examples\commands\data_validation.sps
文件 337 2004-05-11 12:29 examples\commands\datediff.sps
文件 186 2004-05-11 12:30 examples\commands\datesum.sps
文件 430 2004-05-07 08:27 examples\commands\date_functions.sps
文件 474 2006-03-27 12:06 examples\commands\date_functions2.sps
文件 416 2004-05-07 08:28 examples\commands\date_functions3.sps
文件 474 2004-08-05 14:19 examples\commands\decimal_indicator.sps
文件 363 2004-08-05 14:19 examples\commands\define_globals.sps
文件 1401 2004-05-07 08:29 examples\commands\define_variables.sps
文件 247 2004-05-07 08:29 examples\commands\delimited_csv.sps
文件 220 2006-01-04 14:24 examples\commands\delimited_formats.sps
文件 142 2004-05-07 08:29 examples\commands\delimited_list.sps
............此处省略268个文件信息
相关资源
- KUKA 编程案例讲解.ppt
- Scratch 吃豆人追踪者.sb3
- labview编程软件滤波器以及编写程序设
- Scratch 变脸(将人物图片变成各种各样
- UNIX/LINUX编程实践教程的源码
- Windows异步套接字网络编程
- 编程实现二维DCT变换
- MT4编程 EA模板
- 音乐代码转换软件 单片机编程时用
- PLC上位机编程软件
- 一种红外遥控编解码仿真
- 用Socket编程实现FTP
- S7-200模拟量编程实例
- 防火墙编程-Visual C 网络通信开发
- 数据采集系统——ADC0808的应用,单片
- MFC网络编程实例
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- ADC0809数字电压表 LCD1602显示 汇编程序
- 108种编程中常见的问题及解决办法
- Siemens PLC编程精品例程11.机械手GRAPH
- SOCKET 网络编程 计算机网络 作业 客户
- PC汇编编程钢琴程序
- 浙大ACM编程竞赛的摸板
- 武汉大学测绘学院大地测量学编程-
- 武汉大学测绘学院大地测量学编程-
- 操作系统实验综合设计【附代码】
- 汇编编程实现二进制和十六进制之间
- VC 编程实现活动主机扫描源代码
- AT89S ISP下载编程软件(串口)
评论
共有 条评论