Generating data definition syntax based on SPSS sav file

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Generating data definition syntax based on SPSS sav file

Cleland, Patricia (EDU)
Some years ago, someone, possibly Raynald, gave me some syntax that
would generate the data definition syntax for an SPSS system file, that
is for each variable, it would generate the VAR LABEL, VALUE LABEL,
FORMAT, MISSING statements.

In the intervening years, what with changing systems, versions and jobs,
I've lost that syntax.  I've looked at Raynald's website, but it doesn't
look like the syntax I want is there. I've also looked at DevCentral to
see if there's a Python version, but no luck.. Would anyone happen to
have a copy of that syntax?

I know that I can simply apply the dictionary from one file to another,
but that fails if I delete the original file.

Pat

====================To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Generating data definition syntax based on SPSS sav file

Spousta Jan
Pat,

...Radio Yerevan answers: "In principle you are true, but it was not Raynald, rather it was Jan, and it was not a syntax, but a Sax Basic script." (http://en.wikipedia.org/wiki/Radio_Yerevan)

The script (written by Ondrej Hava and myself) is below. As usual, without guarantees of any kind.

Have a nice day,

Jan


'Begin Description
'This script creates a new syntax window containig file and variables definition syntax, 'corresponding with the working data file. Variables and value labels, formats, alignments and measurement 'levels of variables, missing values, filters, splits, and weights are descripted in the syntax.
'It enables you to edit the syntax and change the settings in it, or to re-use parts of the syntax file.
'Requirement: A working SPSS data file must be defined. Then simply run the script.
'Author: Jan Spousta, spousta (et) yahoo.com, and Ondrej Hava 'Known limitations: Does not display missing values of string variables.
'Does Not properly distinguish between SPLIT FILE LAYERED And SEPARAT.
'End Description

Option Explicit

Sub Main

        Dim objDocuments As ISpssDocuments
        Dim objDataDoc As ISpssDataDoc
        Set objDocuments=objSpssApp.Documents
        Set objDataDoc = objDocuments.GetDataDoc(0)
        Dim varMyVariables As Variant
        Dim numVars As Long
        Dim numValueLabels As Long
        Dim vrtValueLabelCounts As Variant
        Dim vrtValueLabels As Variant
        Dim strSyntax, strLabel As String
        Dim I As Long
        Dim J As Long
        Dim c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 As Integer 'Proměnné pro jednotlivá zaškrtátka
        Dim numNoVarlab, numNoVallab, numNoMissing As Long 'Kolik to nemá definované
        Dim strNoVarlab, strNoVallab, strNoMissing As String 'Které to jsou
        numNoVarlab = 0 : numNoVallab = 0 : numNoMissing = 0
        strNoVarlab = "* " : strNoVallab = "* " : strNoMissing = "* " 'Inicializace

        Begin Dialog UserDialog 400,371,"File Formatting Syntax Generator",.dlgFunction ' %GRID:10,7,1,1
                Text 60,14,290,14,"Which properties should the syntax contain?",.Text1
                CheckBox 40,49,150,14,"Variable labels",.CheckBox1
                CheckBox 40,77,120,14,"Value labels",.CheckBox2
                CheckBox 40,105,170,14,"Formats of variables",.CheckBox3
                CheckBox 40,133,140,14,"Missing values",.CheckBox4
                CheckBox 40,161,170,14,"Measurement levels",.CheckBox5
                CheckBox 40,189,180,14,"Alignments of variables",.CheckBox6
                CheckBox 40,217,160,14,"Filtering of the data",.CheckBox7
                CheckBox 40,245,180,14,"Splitting of the data",.CheckBox8
                CheckBox 40,273,180,14,"Weighting of the data",.CheckBox9
                Text 60,350,270,14,"Created by Ondrej Hava and Jan Spousta",.Text2
                CancelButton 280,280,90,21
                OKButton 280,308,90,21
                PushButton 280,189,90,21,"All",.PushButton1
                PushButton 280,217,90,21,"None",.PushButton2
                CheckBox 40,315,200,14,"Display variable comments",.CheckBox10
        End Dialog
        Dim dlg As UserDialog
        Dialog dlg
        c1 = dlg.CheckBox1
        c2 = dlg.CheckBox2
        c3 = dlg.CheckBox3
        c4 = dlg.CheckBox4
        c5 = dlg.CheckBox5
        c6 = dlg.CheckBox6
        c7 = dlg.CheckBox7
        c8 = dlg.CheckBox8
        c9 = dlg.CheckBox9
        c10 = dlg.CheckBox10

        Dim objSyntaxDoc As ISpssSyntaxDoc
        Set objSyntaxDoc=objSpssApp.NewSyntaxDoc
        objSyntaxDoc.Visible = True

        Dim vrtNames, vrtLabels, vrtTypes, vrtMsmtLevels, vrtLabelCounts, vrtVarTypes, vrtWidths, vrtFracts As Variant
        Dim vrtMissingCounts, vrtMissingValues, vrtJust, vrtSplit As Variant
        Dim numInfo As Long
        Dim strNameShort, strName, strSplits, strFile As String
        objDataDoc.GetVariableInfo (vrtNames, vrtLabels, vrtTypes, vrtMsmtLevels, vrtLabelCounts)
        objDataDoc.GetVariableFormats (vrtVarTypes, vrtWidths, vrtFracts)
        objDataDoc.GetVariableMissingValues (vrtMissingCounts, vrtMissingValues)
        objDataDoc.GetVariableJustification (vrtJust)
        numInfo = objDataDoc.GetSplitVariables(vrtSplit)

        objDataDoc.GetDocumentPath
        numVars = objDataDoc.GetNumberOfVariables
        varMyVariables = objDataDoc.GetVariables (True)

        strFile = "File " + objDataDoc.GetDocumentPath
        If strFile = "File " Then strFile = "Untitled Working Data File"

        strSyntax = "*" + vbCrLf + "* Description Syntax For the " + strFile + "." + vbCrLf
        strSyntax = strSyntax + "* " + CStr(numVars) + " variable(s) in the working file, " + CStr(objDataDoc.GetNumberOfCases) + " case(s). Date " + CStr(Date) + ", time " + CStr(Time) + "." + vbCrLf + "*" + vbCrLf

        strSyntax = strSyntax + "* File Formatting Syntax Generator (c) Ondrej Hava (hava (et) spss.cz) & Jan Spousta (spousta (et) yahoo.com), 2001." + vbCrLf + "*." + vbCrLf

        If c7 = 1 And objDataDoc.GetFilterVariable(False) <> "" Then
                strSyntax = strSyntax + vbCrLf + "FILTER BY " + objDataDoc.GetFilterVariable(False) + "." + vbCrLf
        ElseIf c7 = 1 And objDataDoc.GetFilterVariable(False) = "" Then
                strSyntax = strSyntax + vbCrLf + "FILTER OFF." + vbCrLf
        End If
        If c8 = 1 And numInfo > 0 Then
                strSplits = ""
                For J = 0 To numInfo - 1
                        strSplits = strSplits + " " + CStr(vrtSplit(J))
                Next J
                strSyntax = strSyntax + vbCrLf + "SPLIT FILE BY" + strSplits + "." + vbCrLf
        ElseIf c8 = 1 And numInfo = 0 Then
                strSyntax = strSyntax + vbCrLf + "SPLIT FILE OFF." + vbCrLf
        End If
        If c9 = 1 And objDataDoc.GetWeightingVariable(False) <> "" Then
                strSyntax = strSyntax + vbCrLf + "WEIGHT BY " + objDataDoc.GetWeightingVariable(False) + "." + vbCrLf
        ElseIf c9 = 1 And objDataDoc.GetWeightingVariable(False) = "" Then
                strSyntax = strSyntax + vbCrLf + "WEIGHT OFF." + vbCrLf
        End If


        If c1 = 0 And c2 = 0 And c3 = 0 And c4 = 0 And c5 = 0 And c6 = 0 Then GoTo Konec

        For I = 0 To numVars - 1
                strName = varMyVariables(I)
                If InStr(strName,vbTab) > 0 Then
                        strNameShort = Left(varMyVariables(I),InStr(varMyVariables(I),vbTab)-1)
                Else
                        strNameShort = strName
                End If
                If c10 = 1 Then strSyntax = strSyntax + vbCrLf + "* Description of the Variable " + strName + " ." + vbCrLf
                If InStr(strName,vbTab) > 0 And c1 = 1 Then             'Existuje variable label
                        strLabel = Right(varMyVariables(I),Len(varMyVariables(I)) - InStr(varMyVariables(I),vbTab))
                        strSyntax = strSyntax + "VARIABLE LABELS " + strNameShort + " '" + strLabel + "' ." + vbCrLf
                Else    'Neexistuje variable label
                        numNoVarlab = numNoVarlab + 1
                        strNoVarlab = strNoVarlab + " " + strNameShort
                        If numNoVarlab Mod 10 = 0 Then strNoVarlab = strNoVarlab + vbCrLf + "* "
                End If
                numValueLabels = objDataDoc.GetVariableValueLabels (I, vrtValueLabelCounts, vrtValueLabels)
                If numValueLabels > 0 And c2 = 1 Then           'Existuje alspoň jeden value label
                        strSyntax = strSyntax + "VALUE LABELS " + strNameShort
                        For J = 0 To numValueLabels - 1
                                If vrtTypes(I) = 0 Or vrtTypes(I) = 2 Then
                                        strSyntax = strSyntax + vbCrLf + " " + strCarka(vrtValueLabelCounts(J)) + " '" + vrtValueLabels(J) + "'"
                                Else
                                        strSyntax = strSyntax + vbCrLf + " '" + vrtValueLabelCounts(J) + "' '" + vrtValueLabels(J) + "'"
                                End If
                        Next J
                        strSyntax = strSyntax + " ." + vbCrLf
                Else    'Neexistuje žádný value label
                        numNoVallab = numNoVallab + 1
                        strNoVallab = strNoVallab + " " + strNameShort
                        If numNoVallab Mod 10 = 0 Then strNoVallab = strNoVallab + vbCrLf + "* "
                End If
                If c3 = 1 Then 'mají se definovat typy
                        Select Case vrtVarTypes(I)
                        Case 1  'SpssPrintFormatA
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (A" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 2  'SpssPrintFormatAhex
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (AHEX" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 3  'SpssPrintFormatComma
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (COMMA" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 4  'SpssPrintFormatDollar
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DOLLAR" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 5  'SpssPrintFormatF
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (F" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 6  'SpssPrintFormatIb
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (IB" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 7  'SpssPrintFormatPibhex
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PIBHEX" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 8  'SpssPrintFormatP
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (P" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 9  'SpssPrintFormatPib
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PIB" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 10 'SpssPrintFormatPk
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PK" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 11 'SpssPrintFormatRb
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (RB" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 12 'SpssPrintFormatRbhex
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (RBHEX" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 15 'SpssPrintFormatZ
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (Z" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 16 'SpssPrintFormatN
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (N" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 17 'SpssPrintFormatE
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (E" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 20 'SpssPrintFormatDate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 21 'SpssPrintFormatTime
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (TIME" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 22 'SpssPrintFormatDatetime
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DATETIME" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 23 'SpssPrintFormatAdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (ADATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 24 'SpssPrintFormatJdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (JDATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 25 'SpssPrintFormatDtime
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DTIME" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 26 'SpssPrintFormatWkday
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (WKDAY" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 27 'SpssPrintFormatMonth
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (MONTH" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 28 'SpssPrintFormatMoyr
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (MOYR" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 29 'SpssPrintFormatQyr
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (QYR" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 30 'SpssPrintFormatWkyr
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (WKYR" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 31 'SpssPrintFormatPct
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PCT" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 32 'SpssPrintFormatDot
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DOT" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 33 'SpssPrintFormatCca
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCA" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 34 'SpssPrintFormatCcb
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCB" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 35 'SpssPrintFormatCcc
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCC" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 36 'SpssPrintFormatCcd
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCD" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 37 'SpssPrintFormatCce
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCE" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 38 'SpssPrintFormatEdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (EDATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 39 'SpssPrintFormatSdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (SDATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        End Select
                End If
                If c4 = 1 Then 'mají se definovat missingy
                        Select Case vrtMissingCounts(I)
                        Case -3 'interval a bod
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + " THRU " + strCarka(vrtMissingValues(I,1)) + ", " + strCarka(vrtMissingValues(I,2)) + ")." + vbCrLf
                        Case -2 'interval
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + " THRU " + strCarka(vrtMissingValues(I,1)) + ")." + vbCrLf
                        Case 0  'Neexistuje žádný value label
                                numNoMissing = numNoMissing + 1
                                strNoMissing = strNoMissing + " " + strNameShort
                                If numNoMissing Mod 10 = 0 Then strNoMissing = strNoMissing + vbCrLf + "* "
                        Case 1 'bod
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + ")." + vbCrLf
                        Case 2 'dva body
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + ", " + strCarka(vrtMissingValues(I,1)) + ")." + vbCrLf
                        Case 3 'tři body
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + ", " + strCarka(vrtMissingValues(I,1)) + ", " + strCarka(vrtMissingValues(I,2)) + ")." + vbCrLf
                        End Select
                End If
                If c5 = 1 Then 'mají se definovat úrovně měření
                        Select Case vrtMsmtLevels(I)
                        Case 1 'nominal
                                        strSyntax = strSyntax + "VARIABLE LEVEL " + strNameShort + " (NOMINAL)." + vbCrLf
                        Case 2 'ordinal
                                        strSyntax = strSyntax + "VARIABLE LEVEL " + strNameShort + " (ORDINAL)." + vbCrLf
                        Case 3 'scale
                                        strSyntax = strSyntax + "VARIABLE LEVEL " + strNameShort + " (SCALE)." + vbCrLf
                        End Select
                End If
                If c6 = 1 Then 'mají se definovat zarovnání
                        Select Case vrtJust(I)
                        Case 0 'levo
                                        strSyntax = strSyntax + "VARIABLE ALIGNMENT " + strNameShort + " (LEFT)." + vbCrLf
                        Case 1 'pravo
                                        strSyntax = strSyntax + "VARIABLE ALIGNMENT " + strNameShort + " (RIGHT)." + vbCrLf
                        Case 2 'střed
                                        strSyntax = strSyntax + "VARIABLE ALIGNMENT " + strNameShort + " (CENTER)." + vbCrLf
                        End Select
                End If
        Next I

Konec:
        If c1 = 1 And numNoVarlab > 0 Then
                strSyntax = strSyntax + vbCrLf + "* There are " + CStr(numNoVarlab) + " variable(s) with no Variable Labels:" + vbCrLf
                strSyntax = strSyntax + strNoVarlab + "." + vbCrLf
        End If
        If c2 = 1 And numNoVallab > 0 Then
                strSyntax = strSyntax + vbCrLf + "* There are " + CStr(numNoVallab) + " variable(s) with no Value Labels:" + vbCrLf
                strSyntax = strSyntax + strNoVallab + "." + vbCrLf
        End If
        If c4 = 1 And numNoMissing > 0 Then
                strSyntax = strSyntax + vbCrLf + "* There are " + CStr(numNoMissing) + " variable(s) with no Missing Values:" + vbCrLf
                strSyntax = strSyntax + strNoMissing + "." + vbCrLf
        End If


        objSyntaxDoc.Text=strSyntax

End Sub

Private Function dlgFunction(DlgItem$, Action%, SuppValue%) As Boolean
        Select Case Action%
        Case 1 ' Dialog box initialization
                        DlgValue "CheckBox1" , 1
                        DlgValue "CheckBox2" , 1
                        DlgValue "CheckBox10" , 1
        Case 2 ' Value changing or button pressed
        Rem dlgFunction = True ' Prevent button press from closing the dialog box
                Select Case DlgItem$
                Case "PushButton1" 'All
                        DlgValue "CheckBox1" , 1
                        DlgValue "CheckBox2" , 1
                        DlgValue "CheckBox3" , 1
                        DlgValue "CheckBox4" , 1
                        DlgValue "CheckBox5" , 1
                        DlgValue "CheckBox6" , 1
                        DlgValue "CheckBox7" , 1
                        DlgValue "CheckBox8" , 1
                        DlgValue "CheckBox9" , 1
                        dlgFunction = True
                Case "PushButton2" 'None
                        DlgValue "CheckBox1" , 0
                        DlgValue "CheckBox2" , 0
                        DlgValue "CheckBox3" , 0
                        DlgValue "CheckBox4" , 0
                        DlgValue "CheckBox5" , 0
                        DlgValue "CheckBox6" , 0
                        DlgValue "CheckBox7" , 0
                        DlgValue "CheckBox8" , 0
                        DlgValue "CheckBox9" , 0
                        dlgFunction = True
                End Select
                If DlgValue("CheckBox1") = 0 And DlgValue("CheckBox2") = 0 And DlgValue("CheckBox3") = 0 And DlgValue("CheckBox4") = 0 And DlgValue("CheckBox5") = 0 And DlgValue("CheckBox6") = 0 Then
                        DlgEnable "CheckBox10",False
                Else
                        DlgEnable "CheckBox10",True
                End If
        Case 3 ' TextBox or ComboBox text changed
        Case 4 ' Focus changed
        Case 5 ' Idle
                Rem dlgFunction = True ' Continue getting idle actions
        End Select
End Function

Private Function strCarka(Numero) As String 'funkce, která nahradí první výskyt čárky tečkou
        Dim strNumero As String
        Dim numMaximum As Double
        numMaximum = 1.79769E+306 'This is the maximum possible numeric value in the data

        If Numero > numMaximum Then
                strNumero = "HI"
        ElseIf -1 * Numero > numMaximum Then
                strNumero = "LO"
        Else
                strNumero = CStr(Numero)
        End If

        If (InStr(strNumero,",")>0) Then
                strCarka = Left(strNumero,InStr(strNumero,",")-1) + "." + Mid(strNumero,InStr(strNumero,",")+1)
        Else
                strCarka = strNumero
        End If
End Function




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Cleland, Patricia (EDU)
Sent: Tuesday, February 19, 2008 8:30 PM
To: [hidden email]
Subject: Generating data definition syntax based on SPSS sav file

Some years ago, someone, possibly Raynald, gave me some syntax that would generate the data definition syntax for an SPSS system file, that is for each variable, it would generate the VAR LABEL, VALUE LABEL, FORMAT, MISSING statements.

In the intervening years, what with changing systems, versions and jobs, I've lost that syntax.  I've looked at Raynald's website, but it doesn't look like the syntax I want is there. I've also looked at DevCentral to see if there's a Python version, but no luck.. Would anyone happen to have a copy of that syntax?

I know that I can simply apply the dictionary from one file to another, but that fails if I delete the original file.

Pat

=======
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



_____

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

-.- --

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Generating data definition syntax based on SPSS sav file

Cleland, Patricia (EDU)
Thanks, Jan. It works perfectly.

For other listers, below is an example of the output from this Script for the GSS93 subset.sav file (first five variables only)

Pat

***************************************************************************************

*
* Description Syntax For the File C:\UserApps\SPSS\GSS93 subset.sav.
* 67 variable(s) in the working file, 1500 case(s). Date 20/02/2008, time 10:16:56 AM.
*
* File Formatting Syntax Generator (c) Ondrej Hava (hava (et) spss.cz) & Jan Spousta (spousta (et) yahoo.com), 2001.
*.

* Description of the Variable id        Respondent ID Number .
VARIABLE LABELS id 'Respondent ID Number' .
FORMATS id (F4.0).
VARIABLE LEVEL id (SCALE).
VARIABLE ALIGNMENT id (RIGHT).

* Description of the Variable wrkstat   Labor Force Status .
VARIABLE LABELS wrkstat 'Labor Force Status' .
VALUE LABELS wrkstat
 0 'NAP'
 1 'Working fulltime'
 2 'Working parttime'
 3 'Temp not working'
 4 'Unempl, laid off'
 5 'Retired'
 6 'School'
 7 'Keeping house'
 8 'Other'
 9 'NA' .
FORMATS wrkstat (F1.0).
MISSING VALUES wrkstat (0, 9).
VARIABLE LEVEL wrkstat (ORDINAL).
VARIABLE ALIGNMENT wrkstat (RIGHT).

* Description of the Variable marital   Marital Status .
VARIABLE LABELS marital 'Marital Status' .
VALUE LABELS marital
 1 'married'
 2 'widowed'
 3 'divorced'
 4 'separated'
 5 'never married'
 9 'NA' .
FORMATS marital (F1.0).
MISSING VALUES marital (9).
VARIABLE LEVEL marital (ORDINAL).
VARIABLE ALIGNMENT marital (RIGHT).

* Description of the Variable agewed    Age When First Married .
VARIABLE LABELS agewed 'Age When First Married' .
VALUE LABELS agewed
 0 'nap'
 98 'dk'
 99 'na' .
FORMATS agewed (F2.0).
MISSING VALUES agewed (0, 98, 99).
VARIABLE LEVEL agewed (ORDINAL).
VARIABLE ALIGNMENT agewed (RIGHT).

* Description of the Variable sibs      Number of Brothers and Sisters .
VARIABLE LABELS sibs 'Number of Brothers and Sisters' .
VALUE LABELS sibs
 98 'dk'
 99 'na' .
FORMATS sibs (F2.0).
MISSING VALUES sibs (98, 99).
VARIABLE LEVEL sibs (ORDINAL).
VARIABLE ALIGNMENT sibs (RIGHT).

-----Original Message-----
From: Spousta Jan [mailto:[hidden email]]
Sent: February 20, 2008 3:21 AM
To: Cleland, Patricia (EDU); [hidden email]
Subject: RE: Generating data definition syntax based on SPSS sav file

Pat,

...Radio Yerevan answers: "In principle you are true, but it was not Raynald, rather it was Jan, and it was not a syntax, but a Sax Basic script." (http://en.wikipedia.org/wiki/Radio_Yerevan)

The script (written by Ondrej Hava and myself) is below. As usual, without guarantees of any kind.

Have a nice day,

Jan


'Begin Description
'This script creates a new syntax window containig file and variables definition syntax, 'corresponding with the working data file. Variables and value labels, formats, alignments and measurement 'levels of variables, missing values, filters, splits, and weights are descripted in the syntax.
'It enables you to edit the syntax and change the settings in it, or to re-use parts of the syntax file.
'Requirement: A working SPSS data file must be defined. Then simply run the script.
'Author: Jan Spousta, spousta (et) yahoo.com, and Ondrej Hava 'Known limitations: Does not display missing values of string variables.
'Does Not properly distinguish between SPLIT FILE LAYERED And SEPARAT.
'End Description

Option Explicit

Sub Main

        Dim objDocuments As ISpssDocuments
        Dim objDataDoc As ISpssDataDoc
        Set objDocuments=objSpssApp.Documents
        Set objDataDoc = objDocuments.GetDataDoc(0)
        Dim varMyVariables As Variant
        Dim numVars As Long
        Dim numValueLabels As Long
        Dim vrtValueLabelCounts As Variant
        Dim vrtValueLabels As Variant
        Dim strSyntax, strLabel As String
        Dim I As Long
        Dim J As Long
        Dim c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 As Integer 'Proměnné pro jednotlivá zaškrtátka
        Dim numNoVarlab, numNoVallab, numNoMissing As Long 'Kolik to nemá definované
        Dim strNoVarlab, strNoVallab, strNoMissing As String 'Které to jsou
        numNoVarlab = 0 : numNoVallab = 0 : numNoMissing = 0
        strNoVarlab = "* " : strNoVallab = "* " : strNoMissing = "* " 'Inicializace

        Begin Dialog UserDialog 400,371,"File Formatting Syntax Generator",.dlgFunction ' %GRID:10,7,1,1
                Text 60,14,290,14,"Which properties should the syntax contain?",.Text1
                CheckBox 40,49,150,14,"Variable labels",.CheckBox1
                CheckBox 40,77,120,14,"Value labels",.CheckBox2
                CheckBox 40,105,170,14,"Formats of variables",.CheckBox3
                CheckBox 40,133,140,14,"Missing values",.CheckBox4
                CheckBox 40,161,170,14,"Measurement levels",.CheckBox5
                CheckBox 40,189,180,14,"Alignments of variables",.CheckBox6
                CheckBox 40,217,160,14,"Filtering of the data",.CheckBox7
                CheckBox 40,245,180,14,"Splitting of the data",.CheckBox8
                CheckBox 40,273,180,14,"Weighting of the data",.CheckBox9
                Text 60,350,270,14,"Created by Ondrej Hava and Jan Spousta",.Text2
                CancelButton 280,280,90,21
                OKButton 280,308,90,21
                PushButton 280,189,90,21,"All",.PushButton1
                PushButton 280,217,90,21,"None",.PushButton2
                CheckBox 40,315,200,14,"Display variable comments",.CheckBox10
        End Dialog
        Dim dlg As UserDialog
        Dialog dlg
        c1 = dlg.CheckBox1
        c2 = dlg.CheckBox2
        c3 = dlg.CheckBox3
        c4 = dlg.CheckBox4
        c5 = dlg.CheckBox5
        c6 = dlg.CheckBox6
        c7 = dlg.CheckBox7
        c8 = dlg.CheckBox8
        c9 = dlg.CheckBox9
        c10 = dlg.CheckBox10

        Dim objSyntaxDoc As ISpssSyntaxDoc
        Set objSyntaxDoc=objSpssApp.NewSyntaxDoc
        objSyntaxDoc.Visible = True

        Dim vrtNames, vrtLabels, vrtTypes, vrtMsmtLevels, vrtLabelCounts, vrtVarTypes, vrtWidths, vrtFracts As Variant
        Dim vrtMissingCounts, vrtMissingValues, vrtJust, vrtSplit As Variant
        Dim numInfo As Long
        Dim strNameShort, strName, strSplits, strFile As String
        objDataDoc.GetVariableInfo (vrtNames, vrtLabels, vrtTypes, vrtMsmtLevels, vrtLabelCounts)
        objDataDoc.GetVariableFormats (vrtVarTypes, vrtWidths, vrtFracts)
        objDataDoc.GetVariableMissingValues (vrtMissingCounts, vrtMissingValues)
        objDataDoc.GetVariableJustification (vrtJust)
        numInfo = objDataDoc.GetSplitVariables(vrtSplit)

        objDataDoc.GetDocumentPath
        numVars = objDataDoc.GetNumberOfVariables
        varMyVariables = objDataDoc.GetVariables (True)

        strFile = "File " + objDataDoc.GetDocumentPath
        If strFile = "File " Then strFile = "Untitled Working Data File"

        strSyntax = "*" + vbCrLf + "* Description Syntax For the " + strFile + "." + vbCrLf
        strSyntax = strSyntax + "* " + CStr(numVars) + " variable(s) in the working file, " + CStr(objDataDoc.GetNumberOfCases) + " case(s). Date " + CStr(Date) + ", time " + CStr(Time) + "." + vbCrLf + "*" + vbCrLf

        strSyntax = strSyntax + "* File Formatting Syntax Generator (c) Ondrej Hava (hava (et) spss.cz) & Jan Spousta (spousta (et) yahoo.com), 2001." + vbCrLf + "*." + vbCrLf

        If c7 = 1 And objDataDoc.GetFilterVariable(False) <> "" Then
                strSyntax = strSyntax + vbCrLf + "FILTER BY " + objDataDoc.GetFilterVariable(False) + "." + vbCrLf
        ElseIf c7 = 1 And objDataDoc.GetFilterVariable(False) = "" Then
                strSyntax = strSyntax + vbCrLf + "FILTER OFF." + vbCrLf
        End If
        If c8 = 1 And numInfo > 0 Then
                strSplits = ""
                For J = 0 To numInfo - 1
                        strSplits = strSplits + " " + CStr(vrtSplit(J))
                Next J
                strSyntax = strSyntax + vbCrLf + "SPLIT FILE BY" + strSplits + "." + vbCrLf
        ElseIf c8 = 1 And numInfo = 0 Then
                strSyntax = strSyntax + vbCrLf + "SPLIT FILE OFF." + vbCrLf
        End If
        If c9 = 1 And objDataDoc.GetWeightingVariable(False) <> "" Then
                strSyntax = strSyntax + vbCrLf + "WEIGHT BY " + objDataDoc.GetWeightingVariable(False) + "." + vbCrLf
        ElseIf c9 = 1 And objDataDoc.GetWeightingVariable(False) = "" Then
                strSyntax = strSyntax + vbCrLf + "WEIGHT OFF." + vbCrLf
        End If


        If c1 = 0 And c2 = 0 And c3 = 0 And c4 = 0 And c5 = 0 And c6 = 0 Then GoTo Konec

        For I = 0 To numVars - 1
                strName = varMyVariables(I)
                If InStr(strName,vbTab) > 0 Then
                        strNameShort = Left(varMyVariables(I),InStr(varMyVariables(I),vbTab)-1)
                Else
                        strNameShort = strName
                End If
                If c10 = 1 Then strSyntax = strSyntax + vbCrLf + "* Description of the Variable " + strName + " ." + vbCrLf
                If InStr(strName,vbTab) > 0 And c1 = 1 Then             'Existuje variable label
                        strLabel = Right(varMyVariables(I),Len(varMyVariables(I)) - InStr(varMyVariables(I),vbTab))
                        strSyntax = strSyntax + "VARIABLE LABELS " + strNameShort + " '" + strLabel + "' ." + vbCrLf
                Else    'Neexistuje variable label
                        numNoVarlab = numNoVarlab + 1
                        strNoVarlab = strNoVarlab + " " + strNameShort
                        If numNoVarlab Mod 10 = 0 Then strNoVarlab = strNoVarlab + vbCrLf + "* "
                End If
                numValueLabels = objDataDoc.GetVariableValueLabels (I, vrtValueLabelCounts, vrtValueLabels)
                If numValueLabels > 0 And c2 = 1 Then           'Existuje alspoň jeden value label
                        strSyntax = strSyntax + "VALUE LABELS " + strNameShort
                        For J = 0 To numValueLabels - 1
                                If vrtTypes(I) = 0 Or vrtTypes(I) = 2 Then
                                        strSyntax = strSyntax + vbCrLf + " " + strCarka(vrtValueLabelCounts(J)) + " '" + vrtValueLabels(J) + "'"
                                Else
                                        strSyntax = strSyntax + vbCrLf + " '" + vrtValueLabelCounts(J) + "' '" + vrtValueLabels(J) + "'"
                                End If
                        Next J
                        strSyntax = strSyntax + " ." + vbCrLf
                Else    'Neexistuje žádný value label
                        numNoVallab = numNoVallab + 1
                        strNoVallab = strNoVallab + " " + strNameShort
                        If numNoVallab Mod 10 = 0 Then strNoVallab = strNoVallab + vbCrLf + "* "
                End If
                If c3 = 1 Then 'mají se definovat typy
                        Select Case vrtVarTypes(I)
                        Case 1  'SpssPrintFormatA
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (A" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 2  'SpssPrintFormatAhex
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (AHEX" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 3  'SpssPrintFormatComma
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (COMMA" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 4  'SpssPrintFormatDollar
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DOLLAR" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 5  'SpssPrintFormatF
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (F" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 6  'SpssPrintFormatIb
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (IB" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 7  'SpssPrintFormatPibhex
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PIBHEX" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 8  'SpssPrintFormatP
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (P" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 9  'SpssPrintFormatPib
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PIB" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 10 'SpssPrintFormatPk
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PK" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 11 'SpssPrintFormatRb
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (RB" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 12 'SpssPrintFormatRbhex
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (RBHEX" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 15 'SpssPrintFormatZ
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (Z" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 16 'SpssPrintFormatN
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (N" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 17 'SpssPrintFormatE
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (E" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 20 'SpssPrintFormatDate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 21 'SpssPrintFormatTime
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (TIME" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 22 'SpssPrintFormatDatetime
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DATETIME" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 23 'SpssPrintFormatAdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (ADATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 24 'SpssPrintFormatJdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (JDATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 25 'SpssPrintFormatDtime
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DTIME" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 26 'SpssPrintFormatWkday
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (WKDAY" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 27 'SpssPrintFormatMonth
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (MONTH" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 28 'SpssPrintFormatMoyr
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (MOYR" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 29 'SpssPrintFormatQyr
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (QYR" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 30 'SpssPrintFormatWkyr
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (WKYR" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 31 'SpssPrintFormatPct
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (PCT" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 32 'SpssPrintFormatDot
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (DOT" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 33 'SpssPrintFormatCca
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCA" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 34 'SpssPrintFormatCcb
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCB" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 35 'SpssPrintFormatCcc
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCC" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 36 'SpssPrintFormatCcd
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCD" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 37 'SpssPrintFormatCce
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (CCE" + CStr(vrtWidths(I)) + "." + CStr(vrtFracts(I)) + ")." + vbCrLf
                        Case 38 'SpssPrintFormatEdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (EDATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        Case 39 'SpssPrintFormatSdate
                                strSyntax = strSyntax + "FORMATS " + strNameShort + " (SDATE" + CStr(vrtWidths(I)) + ")." + vbCrLf
                        End Select
                End If
                If c4 = 1 Then 'mají se definovat missingy
                        Select Case vrtMissingCounts(I)
                        Case -3 'interval a bod
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + " THRU " + strCarka(vrtMissingValues(I,1)) + ", " + strCarka(vrtMissingValues(I,2)) + ")." + vbCrLf
                        Case -2 'interval
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + " THRU " + strCarka(vrtMissingValues(I,1)) + ")." + vbCrLf
                        Case 0  'Neexistuje žádný value label
                                numNoMissing = numNoMissing + 1
                                strNoMissing = strNoMissing + " " + strNameShort
                                If numNoMissing Mod 10 = 0 Then strNoMissing = strNoMissing + vbCrLf + "* "
                        Case 1 'bod
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + ")." + vbCrLf
                        Case 2 'dva body
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + ", " + strCarka(vrtMissingValues(I,1)) + ")." + vbCrLf
                        Case 3 'tři body
                                        strSyntax = strSyntax + "MISSING VALUES " + strNameShort + " (" + strCarka(vrtMissingValues(I,0)) + ", " + strCarka(vrtMissingValues(I,1)) + ", " + strCarka(vrtMissingValues(I,2)) + ")." + vbCrLf
                        End Select
                End If
                If c5 = 1 Then 'mají se definovat úrovně měření
                        Select Case vrtMsmtLevels(I)
                        Case 1 'nominal
                                        strSyntax = strSyntax + "VARIABLE LEVEL " + strNameShort + " (NOMINAL)." + vbCrLf
                        Case 2 'ordinal
                                        strSyntax = strSyntax + "VARIABLE LEVEL " + strNameShort + " (ORDINAL)." + vbCrLf
                        Case 3 'scale
                                        strSyntax = strSyntax + "VARIABLE LEVEL " + strNameShort + " (SCALE)." + vbCrLf
                        End Select
                End If
                If c6 = 1 Then 'mají se definovat zarovnání
                        Select Case vrtJust(I)
                        Case 0 'levo
                                        strSyntax = strSyntax + "VARIABLE ALIGNMENT " + strNameShort + " (LEFT)." + vbCrLf
                        Case 1 'pravo
                                        strSyntax = strSyntax + "VARIABLE ALIGNMENT " + strNameShort + " (RIGHT)." + vbCrLf
                        Case 2 'střed
                                        strSyntax = strSyntax + "VARIABLE ALIGNMENT " + strNameShort + " (CENTER)." + vbCrLf
                        End Select
                End If
        Next I

Konec:
        If c1 = 1 And numNoVarlab > 0 Then
                strSyntax = strSyntax + vbCrLf + "* There are " + CStr(numNoVarlab) + " variable(s) with no Variable Labels:" + vbCrLf
                strSyntax = strSyntax + strNoVarlab + "." + vbCrLf
        End If
        If c2 = 1 And numNoVallab > 0 Then
                strSyntax = strSyntax + vbCrLf + "* There are " + CStr(numNoVallab) + " variable(s) with no Value Labels:" + vbCrLf
                strSyntax = strSyntax + strNoVallab + "." + vbCrLf
        End If
        If c4 = 1 And numNoMissing > 0 Then
                strSyntax = strSyntax + vbCrLf + "* There are " + CStr(numNoMissing) + " variable(s) with no Missing Values:" + vbCrLf
                strSyntax = strSyntax + strNoMissing + "." + vbCrLf
        End If


        objSyntaxDoc.Text=strSyntax

End Sub

Private Function dlgFunction(DlgItem$, Action%, SuppValue%) As Boolean
        Select Case Action%
        Case 1 ' Dialog box initialization
                        DlgValue "CheckBox1" , 1
                        DlgValue "CheckBox2" , 1
                        DlgValue "CheckBox10" , 1
        Case 2 ' Value changing or button pressed
        Rem dlgFunction = True ' Prevent button press from closing the dialog box
                Select Case DlgItem$
                Case "PushButton1" 'All
                        DlgValue "CheckBox1" , 1
                        DlgValue "CheckBox2" , 1
                        DlgValue "CheckBox3" , 1
                        DlgValue "CheckBox4" , 1
                        DlgValue "CheckBox5" , 1
                        DlgValue "CheckBox6" , 1
                        DlgValue "CheckBox7" , 1
                        DlgValue "CheckBox8" , 1
                        DlgValue "CheckBox9" , 1
                        dlgFunction = True
                Case "PushButton2" 'None
                        DlgValue "CheckBox1" , 0
                        DlgValue "CheckBox2" , 0
                        DlgValue "CheckBox3" , 0
                        DlgValue "CheckBox4" , 0
                        DlgValue "CheckBox5" , 0
                        DlgValue "CheckBox6" , 0
                        DlgValue "CheckBox7" , 0
                        DlgValue "CheckBox8" , 0
                        DlgValue "CheckBox9" , 0
                        dlgFunction = True
                End Select
                If DlgValue("CheckBox1") = 0 And DlgValue("CheckBox2") = 0 And DlgValue("CheckBox3") = 0 And DlgValue("CheckBox4") = 0 And DlgValue("CheckBox5") = 0 And DlgValue("CheckBox6") = 0 Then
                        DlgEnable "CheckBox10",False
                Else
                        DlgEnable "CheckBox10",True
                End If
        Case 3 ' TextBox or ComboBox text changed
        Case 4 ' Focus changed
        Case 5 ' Idle
                Rem dlgFunction = True ' Continue getting idle actions
        End Select
End Function

Private Function strCarka(Numero) As String 'funkce, která nahradí první výskyt čárky tečkou
        Dim strNumero As String
        Dim numMaximum As Double
        numMaximum = 1.79769E+306 'This is the maximum possible numeric value in the data

        If Numero > numMaximum Then
                strNumero = "HI"
        ElseIf -1 * Numero > numMaximum Then
                strNumero = "LO"
        Else
                strNumero = CStr(Numero)
        End If

        If (InStr(strNumero,",")>0) Then
                strCarka = Left(strNumero,InStr(strNumero,",")-1) + "." + Mid(strNumero,InStr(strNumero,",")+1)
        Else
                strCarka = strNumero
        End If
End Function




-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Cleland, Patricia (EDU)
Sent: Tuesday, February 19, 2008 8:30 PM
To: [hidden email]
Subject: Generating data definition syntax based on SPSS sav file

Some years ago, someone, possibly Raynald, gave me some syntax that would generate the data definition syntax for an SPSS system file, that is for each variable, it would generate the VAR LABEL, VALUE LABEL, FORMAT, MISSING statements.

In the intervening years, what with changing systems, versions and jobs, I've lost that syntax.  I've looked at Raynald's website, but it doesn't look like the syntax I want is there. I've also looked at DevCentral to see if there's a Python version, but no luck.. Would anyone happen to have a copy of that syntax?

I know that I can simply apply the dictionary from one file to another, but that fails if I delete the original file.

Pat

=======
To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD



_____

Tato zpráva a všechny připojené soubory jsou důvěrné a určené výlučně adresátovi(-ům). Jestliže nejste oprávněným adresátem, je zakázáno jakékoliv zveřejňování, zprostředkování nebo jiné použití těchto informací. Jestliže jste tento mail dostali neoprávněně, prosím, uvědomte odesilatele a smažte zprávu i přiložené soubory. Odesilatel nezodpovídá za jakékoliv chyby nebo opomenutí způsobené tímto přenosem.

This message and any attached files are confidential and intended solely for the addressee(s). Any publication, transmission or other use of the information by a person or entity other than the intended addressee is prohibited. If you receive this in error please contact the sender and delete the message as well as all attached documents. The sender does not accept liability for any errors or omissions as a result of the transmission.

-.- --

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD