STATISTICA







Using STADEV with STATISTICA BASIC
More sophisticated reading of data

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

Note that to use STADEV from STATISTICA BASIC you must put stadev.dll and stadev.inc files in the STATISTICA directory, include the development environment include file at the beginning of the program {$I:'stadev.inc'}, and call the appropriate functions.


{$I:'stadev.inc'}

if 0 = SelectOpenFileName (?Title$, fn$, ".sta") then Exit;

writeln ("STATISTICA file information");
writeln;
h := StaOpenFile (fn$);
writeln ("File name:", fn$);

nv := StaGetNVars (h);
writeln ("Number of variables:", nv);

nc := StaGetNCases (h);
writeln ("Number of cases:", nc);

StaGetFileHeader (h, fh$, 80);
writeln ("File header:", fh$);
writeln;

writeln ("Variable specs:");
for i:=1 to nv do
begin
	StaGetVarName (h, i, vn$);
	StaGetVarLongName (h, i, lvn$, 128);
	writeln ("Variable ", i, ": ", vn$, "     ", lvn$);
	StaGetVarFormat (h, i, wid, dec, type, subt);
	writeln ("Format: ", wid, ".", dec);
	StaGetVarMD (h, i, md);
	writeln ("Missing Data: ", md)
end;
writeln;

writeln ("Case names:");
writeln;
cnl := StaGetCaseNameLength (h);
if cnl = 0 then
	writeln ("No case names in this file")
else
begin
	writeln ("CN Length: ", cnl);
	for i := 1 to nc do
	begin
		StaGetCaseName (h, i, cn$, 20);
		writeln ("Case # ", i, ": ", cn$)
	end
end;

for i := 1 to nc do
begin
	writeln ("Case # ", i, ":");
	for j := 1 to nv do
	begin
		StaGetData (h, j, i, d);
		write (d);
		if 0 <> StaGetLabelForValue (h, j, d, lab$) then
		begin
			write ("(", lab$);
			if 0 <> StaGetLongLabelForValue (h, j, d, llab$, 128) then
				write (",", llab$);
			write (") ")
		end
	end;
	writeln;
end;

StaCloseFile (h); 
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.