I have a large datafile in the order of 10K variables, some strig and
most numeric, and I would like to get a list of all string variables
in my database.
Is this possible???
Hello,
If you use SPSS 14 and above, you can do this with a small python
program:
GET FILE = YourFile.
BEGIN PROGRAM PYTHON.
import spss
N=spss.GetVariableCount()
VarList=[]
for i in xrange(N):
if spss.GetVariableMeasurementLevel(i) in ['ordinal', 'nominal']:
VarList.append(spss.GetVariableName(i))
print ' '.join(VarList)
END PROGRAM.
HTH,
Baiyun
Hi:
I don´t have SPSS 14, I´m using version 13... Any way to do it without
Python???
Regards,
I have v16, and don't remember if all of this worked exactly the same
in v13 or not. But some variant of it should work, if it does need
tweaking.
* Get a list of string variables in the car sales data file .
GET FILE='C:\Program Files\SPSS\Samples\car_sales.sav'.
* NOTE: On your PC, the file may be in the main SPSS folder
* rather than in a "Samples" sub-folder. Adjust the syntax
* accordingly.
* Use OMS to write the file info to a file.
OMS
/SELECT TABLES
/IF COMMANDS = ['File Information']
SUBTYPES = ['Variable Information']
/DESTINATION FORMAT = SAV NUMBERED = file viewer = yes
OUTFILE = "C:\temp\variable information.sav".
* Get the file information.
display dictionary.
OMSEND.
* Open the file containing file info.
get file = "C:\temp\variable information.sav".
* Select the rows that have an A-format in variable
* PRINTFORMAT and list the variable names.
temporary.
select if (substr(printformat,1,1) EQ "A").
list var1.
* --------------------------------------- .
--
Bruce Weaver
bwe...@lakeheadu.ca
www.angelfire.com/wv/bwhomedir
"When all else fails, RTFM."