Skip to main content
MedCalc
Mail a PDF copy of this page to:
(Your email address will not be added to a mailing list)
working
Show menu

Fill column

Command:Tools
Next selectFill column

Description

Fills an entire column in the spreadsheet, or a range of rows in a column, with a value or formula. The Fill column command can also be used to clear a range of cells in a column.

You can select two options:

Click fx to call the Variable editor dialog box.

In the following example, rows 1 to 100 of column A will be filled with the result of the RANDNORM(0,1) function. This function generates random numbers drawn from a Normal distribution with mean 0 and standard deviation 1.

Fill column with formula

When you save the data then the formulas that you have entered in this dialog box will also be saved in the MedCalc data file, so you can easily re-use them at a later stage.

The Fill column command can also be used to clear a range of cells in a column, by letting the Fill with field in the dialog box blank.

Some examples of useful formulas are given in the following table.

Fill with: Result:
SQRT(LENGTH) fill with the square root of variable LENGTH
IF(var<20,"A","B") recoding of variable var into two classes A and B
RAND(2) the cells will be filled with 1 or 2 at random
RANDNORM(0,1) fill with random numbers from a Normal distribution with mean 1 and standard deviation 0
VAR1+VAR2 fill with the sum of variables VAR1 and VAR2
ROW the cells will be filled with the row number
  the cells will be cleared (empty Fill with field)

How to convert a continuous variable into a dichotomous variable using the IF function

You can convert a continuous variable into a dichotomous variable by filling a column in the spreadsheet with an IF function.

The general format of this function is:

IF( Condition, result for TRUE condition, result for FALSE condition)

E.g. you have a variable AGE, that you want to convert into codes for two age groups, code 1 for age less than 30 years and code 2 for 30 years or more. You can create a new variable by entering the foluma

IF( AGE < 30 , 1 , 2 )

in the "Fill with" field of the Fill column dialog box shown above.

Note:

See also