Note that this program assumes that you loaded test.txt into the C:\stat directory. This can easily be changed by adjusting the file names in the obvious places below.
Program written, modified, or edited at StatSoft, Inc.}
{$I:'stadev.inc'}
RandomAccess;
ReDim mymatrix(25,12);
{read the comma delimited text file into a matrix}
MatrixRead ('c:\stat\test.txt', mymatrix);
{create a blank .sta file}
handle:=StaCreateFile(12, 25, "c:\stat\test.sta");
{add a one-line header for this new .sta file}
StaSetFileHeader(handle, "Advertising Effectiveness Study.");
{fill the .sta file with the matrix values}
for i:= 1 to 25 do
for j:=1 to 12 do
StaSetData(handle, j, i, mymatrix(i,j));
{add variable names for all variables}
StaSetVarName(handle, 1, "GENDER");
StaSetVarName(handle, 2, "ADVERT");
StaSetVarName(handle, 3, "MEASUR1");
StaSetVarName(handle, 4, "MEASUR2");
StaSetVarName(handle, 5, "MEASUR3");
StaSetVarName(handle, 6, "MEASUR4");
StaSetVarName(handle, 7, "MEASUR5");
StaSetVarName(handle, 8, "MEASUR6");
StaSetVarName(handle, 9, "MEASUR7");
StaSetVarName(handle, 10, "MEASUR8");
StaSetVarName(handle, 11, "MEASUR9");
StaSetVarName(handle, 12, "MEASUR10");
{add long variable names to variable 1 & 2}
StaSetVarLongName(handle, 1, "Gender of the subjects (May 15, 1996).");
StaSetVarLongName(handle, 2, "Ad shown to the subjects (May 15, 1996).");
{set format & missing data code for all variables}
for j:=1 to 12 do begin
StaSetVarFormat(handle, j, 8, 0, 0, 0);
StaSetVarMD(handle, j, -9999);
end;
{set case names & length}
for i:=1 to 25 do begin
name$:="Case "+str(i, 2, 0);
StaSetCaseNameLength(handle, 10);
StaSetCaseName(handle, i, name$);
end;
{add text values for variables 1 & 2}
StaAddLabel(handle, 1, 1, "MALE", "Male students in Tulsa");
StaAddLabel(handle, 1, 2, "FEMALE", "Female students in Tulsa");
StaAddLabel(handle, 2, 1, "PEPSI", "");
StaAddLabel(handle, 2, 2, "COKE", "");
{close the .sta file}
StaCloseFile(handle);
Exit;
| Back to List of Programs |
![[StatSoft]](../../../images/sssmall.gif)
2300 East 14th Street, Tulsa, OK 74104
Phone: (918) 749-1119; Fax: (918) 749-2217
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.