全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SPSS论坛
1436 1
2014-05-14
Hi I am new to SPSS and I am looking for a syntax to delete variables than have width more than 500.

I want to delete all string variables themselves that are more than 500 characters. So far I have only managed to find the syntax to delete all string variables and variables that begin with BP.

begin program.
import spss, spssaux
dict2=spssaux.VariableDict(pattern='^BP')
dict1=spssaux.VariableDict(variableType='string')
vars1 = " ".join(dict1.variables)
vars2 = " ".join(dict2.variables)
dropvars=vars1+ " " +vars2
spss.Submit("Delete Variable " + dropvars)
end program.

Please let me know how I can perhaps modify this to include the condition that the string variables that have to be deleted have width more than 500.

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2014-5-14 01:35:16
begin program.
import spss, spssaux

vardict = spssaux.VariableDict(variableType="string")
verylong = [v.VariableName for v in vardict if v.VariableType > 500]
if verylong:
    spss.Submit("delete variables " + " ".join(verylong))
end program.


Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
peck@us.ibm.com
phone: 720-342-5621
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群