STATISTICA







STATISTICA BASIC Program RepMeas.stb

{ This program will restructure a data file, so that the values for selected variables become consecutive "groups" in a new data file; that data file will also include a grouping variable with text values that are identical to the original variable names.

For example, suppose your data in the current file are arranged like this:
 Males Females
1
2
3
4
4.5
3.9
2.3
---
5.6
6.7
3.3
3.5
After running this program, the new file will look like this:
  Var_1 Var_2
1
2
3
4
5
6
7
Males
Males
Males
Females
Females
Females
Females
4.5
3.9
2.3
5.6
6.7
3.3
3.5
The program will first create a Scrollsheet with the restructured data, and then prompt you to specify the name of the file, where the Scrollsheet is to be saved (as a data file).

Program written, modified, or edited at StatSoft, Inc.}


NoDataFileVariableNames;
RandomAccess;

const MAX_VARS = 10;
dim VarList(MAX_VARS);

if not SelectVariables1 ('Variables to be recoded', 2, MAX_VARS, VarList, nbVars, 'Variables:') then
  Exit;

ReDim array (nbVars*NCases, 2);

for i:=1 to nbVars do
begin
  MatrixCopy (data, 1, VarList(i), NCases, 1, array, NCases * (i-1)+1, 2);
  MatrixFill (i, array, NCases * (i-1)+1, 1, NCases, 1);
end;

scr:=NewScrollsheet (?NoOfRows, ?NoOfColumns, array, 'Recoded data', ?RowNames$,
                                'GROUP|VALUES');
for i:=1 to nbVars do
  for j:=1 to NCases do
     ScrollsheetSetTextValue (scr, NCases * (i-1)+j, 1, VarName(VarList(i)));

if SelectSaveFileName ('Save File As', FileName$, '.STA') then
  SaveScrollsheetAsDataFile (scr, FileName$);
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.