资源简介
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个文件信息
相关资源
- Expert C Programming Deep C Secrets (C 专家编
- YaHei Consolas hybrid 混合字体 修正雅黑偏
- AMX,快思聪,CREATOR,ITAV中控编程教程
- PHStat2 3.5 著名的EXCEL统计插件
- PHStat 4.1 著名的EXCEL统计插件
- 三菱 FX系列PLC编程手册中文
- Visual FORTRAN编程指南PDF非常好的教程
- UNIX网络编程卷1(第三版 英文版)
- 数据挖掘原理与SPSS-Clementine应用宝典
- Sodick 沙迪克UTY编程软件中文版原版破
- Windows程序设计(第五版 经典) pdf
- 《Go语言编程》高清完整版电子书.p
- 深入浅出谈CUDA.
- 计量统计历险记
- Consolas雅黑混合版字体 keil5用
- ar9341博信通信编程器固件
- Unifi ap编程器固件 7240+9283
- 2000年中国城市统计年鉴
- 在Yale 人脸库上运用PCA+SVM的方法实现
- J750 Basic Programming Class Student Manual
- LJV7000 LabVIEW demo
- Scratch课件
- GPRS编程DTU资料
- 浙江大学概率论与数理统计第三版P
- SINUMERIK 840D/840Di/810D基础部分编程说明
- TP_841N_V7__4M编程器固件
- SI4432IA4432中文手册完整版和中文编程
- 统计学原理复旦大学
- 雅黑-Consolas混合字体
- 洪楠MINITAB统计分析教程
评论
共有 条评论