Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding String Variables

2 views
Skip to first unread message

Eugenio

unread,
May 9, 2008, 5:55:20 PM5/9/08
to
Hi Guys:

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???

baiyun

unread,
May 13, 2008, 4:42:14 AM5/13/08
to

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

Eugenio

unread,
May 14, 2008, 11:27:27 AM5/14/08
to

Hi:

I don´t have SPSS 14, I´m using version 13... Any way to do it without
Python???

Regards,

Bruce Weaver

unread,
May 14, 2008, 1:15:41 PM5/14/08
to

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."

0 new messages