STATISTICA







Using STADEV with Visual Basic (16 Bit)
Reading a file

This example dumps to a debug window all information about the STATISTICA data file, including variable specifications and data values with labels.

Note that to use STADEV from 16 bit Visual Basic, you must create a module containing STATISTICA Development Environment VB header file (sd_vb16.inc), call the desired functions, and put stadev32.dll on the path or in VB directory (so it is visible for VB run time).


Private Sub example1(fname$)

Debug.Print ("STATISTICA file information")

H = StaOpenFile(fname$)
If H = 0 Then Exit Sub
Debug.Print "File name:", fname$

nv = StaGetNVars(H)
Debug.Print "Number of variables:", nv

NC = StaGetNCases(H)
Debug.Print "Number of cases:", NC

res = StaGetFileHeader(H, fh$, STAMAX_HEADERLEN + 1)
Debug.Print "File header:", fh$

Dim wid As Integer
Dim dec As Integer
Dim typ As Integer
Dim subt As Integer
Dim md As Double
Debug.Print "Variable specs:"
For i = 1 To nv
    res = StaGetVarName(H, i, vn$)
    res = StaGetVarLongName(H, i, lvn$, STAMAX_LONGVARNAMELEN + 1)
    Debug.Print "Variable ", i, ": ", vn$, "     ", lvn$
    res = StaGetVarFormat(H, i, wid, dec, typ, subt)
    Debug.Print "Format: ", wid, ".", dec
    res = StaGetVarMD(H, i, md)
    Debug.Print "Missing Data: ", md
Next i

Debug.Print "Case names:"
cnl = StaGetCaseNameLength(H)
If cnl = 0 Then
    Debug.Print "No case names in this file"
Else
    Debug.Print "CN Length: ", cnl
    For i = 1 To NC
        res = StaGetCaseName(H, i, cn$, 20)
        Debug.Print "Case # ", i, ": ", cn$
    Next i
End If

Dim d As Double
For i = 1 To NC
    Debug.Print "Case # ", i, ":"
    For j = 1 To nv
        res = StaGetData(H, j, i, d)
        Debug.Print d
        If 0 <> StaGetLabelForValue(H, j, d, lab$) Then
            Debug.Print "(", lab$
            If 0 <> StaGetLongLabelForValue(H, j, d, llab$, STAMAX_LLABELLEN + 1) Then
                Debug.Print ",", llab$
            End If
            Debug.Print ") "
        End If
    Next j
Next i

StaCloseFile (H)
End Sub
Back to List of Programs



[StatSoft]
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217

[StatSoft]e-mail: info@statsoft.com

©Copyright StatSoft, Inc., 1984-2004.
StatSoft, StatSoft logo, STATISTICA, SEWSS, SEDAS, Data Miner, SEPATH and GTrees are trademarks of StatSoft, Inc.