The following program is written in True BASIC but will run in other dialects of BASIC with minor modifications.
BASIC expects comma-delimited input lines, MINITAB can save as tab-delimited. One way to get a comma-delimited file is to open the tab-delimited file with a word processor or text editor and use "Change All" to change every tab to a comma, then save again as a text file.
The ASCII code for a tab is 9. The BASIC program writes chr$(9) between values in the output line. This comes out as a tab character so the resulting file is tab-delimited, ready to import into any spreadsheet or statistics package.
I have used the fact that the first 128 rows are unilateral cases and the remaining rows are in consecutive pairs for the bilateral cases.
In the reorganized data, "clear" becomes the total number of cleared ears for the child, the original variable "ear" has been dropped, and the new variable "num_ears" is the number of ears originally infected (1 for unilateral, 2 for bilateral).
! This program reads in the file EAR.CMA, which is just the file EAR.MTP saved in ! comma-delimited format. Cases 1 to 128 are unilateral and are written to file ! EAR2.TAB in tab-delimited format. The remaining cases are bilateral and the ! two rows for each case are combined into a single tab-delimited row where ! clear is now the total number of ears cleared out of the two infected ears. ! The new variable num_ears gives the number of infected ears (1 for unilateral, ! 2 for bilateral) for each child. ! ! Code modified 1998-01-15 to make the PRINT statements easier to read. ! OPEN #1: name "ear.cma", org text, create old, access input OPEN #2: name "ear2.tab", org text, create newold ERASE #2 LET unilateral=1 LET bilateral=2 LET tb$=chr$(9) ! Print the column headings tab-delimited PRINT #2: "id"; tb$; "clear"; tb$; "antibio"; tb$; "age"; tb$; "num_ears" DO WHILE more #1 INPUT #1: id, clear, antibio, age, ear ! Read a row. IF id <= 128 then ! Unilateral case. ! Print the line tab-delimited. PRINT #2: id; tb$; clear; tb$; antibio; tb$; age; tb$; unilateral ELSE ! Bilateral case, so read the next row. INPUT #1: id2, clear2, antibio2, age2, ear2 ! Make sure the two rows match; stop if they don't. IF id<>id2 or antibio<>antibio2 or age<>age2 then PRINT "Error at id = "; id CLOSE #1 CLOSE #2 STOP END IF ! Compute total number of ears cleared and print the line tab-delimited. PRINT #2: id; tb$; clear+clear2; tb$; antibio; tb$; age; tb$; bilateral END IF LOOP CLOSE #1 CLOSE #2 STOP END
126.0000, 0.0000, 2.0000, 3.0000, 1.0000 127.0000, 0.0000, 2.0000, 3.0000, 1.0000 128.0000, 0.0000, 2.0000, 3.0000, 1.0000 129.0000, 1.0000, 1.0000, 1.0000, 1.0000 129.0000, 1.0000, 1.0000, 1.0000, 2.0000 130.0000, 1.0000, 1.0000, 1.0000, 1.0000 130.0000, 1.0000, 1.0000, 1.0000, 2.0000 131.0000, 1.0000, 1.0000, 1.0000, 1.0000 131.0000, 1.0000, 1.0000, 1.0000, 2.0000 132.0000, 1.0000, 1.0000, 1.0000, 1.0000 132.0000, 1.0000, 1.0000, 1.0000, 2.0000
id |
clear |
antibio |
age |
num_ears |
126 |
0 |
2 |
3 |
1 |
127 |
0 |
2 |
3 |
1 |
128 |
0 |
2 |
3 |
1 |
129 |
2 |
1 |
1 |
2 |
130 |
2 |
1 |
1 |
2 |
131 |
2 |
1 |
1 |
2 |
132 |
2 |
1 |
1 |
2 |