Keeping original variable order with 'select variables' command

允我心安 提交于 2019-12-13 01:28:20

问题


The following code was used to generate a list of numeric variables and their maxima and minima from a datafile containing >500 variables and >2000 cases:

OMS select tables
/if commands=["descriptives"]
subtypes=["descriptive statistics"]
/DESTINATION FORMAT = SAV
OUTFILE = "C:\statyMcStatFace.sav".

SPSSINC SELECT VARIABLES MACRONAME="!nums" /PROPERTIES TYPE= NUMERIC.

DESCRIPTIVES !nums /STATISTICS=MIN MAX.

omsend.

Sadly, the variables weren't listed in the same order in the output file as they were in the original file, nor according to any discernible order I can see. For example, if you run the given code on plantar_fascitiitis.csv at

kaggle.com/rameessahlu/plantar-fasciitis

you'll find that the order of the variables in the original table is age, sex, weight... etc., while the order the variables are listed in the macro is Status, TendernessOfFoot, Alignment, Burning... etc.. Why does this happen, and is there a way for me to order the variables as they are in the original table?


回答1:


When you are creating your numerical variables list using the select variables command, there is an option to keep the created list in the original order of the dataset. So all you have to do is use the command with this addition:

SPSSINC SELECT VARIABLES MACRONAME="!nums" /PROPERTIES TYPE= NUMERIC /OPTIONS ORDER=FILE.


来源:https://stackoverflow.com/questions/58700525/keeping-original-variable-order-with-select-variables-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!