Create a binary variable online
The Binary Variable Generator lets you create a new binary variable from one or more conditions in an existing CSV or Excel dataset.
A binary variable normally contains two values, such as 1 and 0, Yes and No, or Eligible and Not Eligible. The original variables are preserved and the new variable is appended as the last column.
Create a dummy or indicator variable
Binary variables are also commonly called dummy variables or indicator variables. They are frequently used in statistical analysis, survey research, regression models, reporting and data preparation.
For example, you could create an adult variable where age 18 or above receives 1 and age below 18 receives 0.
Similar to creating a binary variable in SPSS
Statistical packages such as SPSS allow users to create or recode variables based on logical conditions. This online tool follows the same general idea: define the condition, choose the output values and create a new variable without replacing your original data.
The tool is not SPSS itself, but it can help perform common binary-variable creation tasks without statistical software.
How to create a binary variable
- Upload a CSV, XLSX or XLS file, or paste CSV data.
- Select the worksheet if you are using an Excel workbook.
- Click Load Variables.
- Enter a name for the new variable.
- Choose the value to assign when the condition is true and the value to assign when it is false.
- Select a source variable, comparison operator and comparison value.
- Add additional conditions if needed.
- Choose AND or OR when using multiple conditions.
- Click Create Binary Variable.
- Download the resulting CSV or Excel dataset.
Binary variable example
Suppose your data contains:
name,age,city Ali,22,Islamabad Sara,17,Lahore David,42,Islamabad Ayesha,31,Karachi
You could define:
New variable: adult Condition: age >= 18 True value: 1 False value: 0
The result becomes:
name,age,city,adult Ali,22,Islamabad,1 Sara,17,Lahore,0 David,42,Islamabad,1 Ayesha,31,Karachi,1
Use multiple conditions with AND
AND means every condition must be true. For example:
age >= 18 AND city = Islamabad
A record receives the true value only when both conditions are satisfied.
Use multiple conditions with OR
OR means at least one condition must be true. For example:
city = Islamabad OR city = Lahore
Records from either Islamabad or Lahore receive the true value.
Supported conditions
| Condition | Example |
|---|---|
| Equals | sex = Female |
| Does not equal | status ≠ Closed |
| Greater than | income > 50000 |
| Greater than or equal | age >= 18 |
| Less than | score < 50 |
| Less than or equal | age <= 17 |
| Contains | city contains Islam |
| Is blank | email is blank |
| Is not blank | phone is not blank |
Choose your own binary values
Binary variables do not have to use only 1 and 0. You can specify your own values, such as Yes and No, Eligible and Not Eligible, Present and Absent, or any other two-category coding scheme.
Original variables are preserved
The generator does not overwrite the variables used in your conditions. The newly created binary variable is appended as the last column of the dataset.
CSV and Excel support
You can create binary variables from CSV, XLSX and XLS files. Excel workbooks with multiple worksheets can be opened by selecting the worksheet containing the data you want to process.
Common uses for binary variables
Binary variables are commonly used in survey analysis, regression modelling, demographic research, monitoring and evaluation, health research, eligibility rules, customer segmentation, reporting and many other analytical workflows.
Is my data uploaded?
No. Your CSV or Excel dataset is processed locally in your browser. The file does not need to be uploaded to MK Tech Tools for variable creation.
Frequently asked questions
Can I create a binary variable online?
Yes. Upload a CSV or Excel dataset, define one or more conditions and specify the values to assign when those conditions are true or false.
Can I create a 0/1 variable?
Yes. Set the true value to 1 and the false value to 0.
Is a binary variable the same as a dummy variable?
The terms are often used similarly. A dummy or indicator variable commonly represents whether a condition or category is present using two values such as 1 and 0.
Can I use more than one condition?
Yes. Add multiple conditions and combine them using AND or OR logic.
Can I use numeric conditions such as age greater than or equal to 18?
Yes. The tool supports greater than, greater than or equal, less than and less than or equal comparisons for numeric data.
Can I use text conditions?
Yes. You can test whether text equals, does not equal, contains or does not contain a value.
Can I check whether a field is blank?
Yes. Is blank and Is not blank conditions are supported.
Does the new variable replace my existing variables?
No. Your existing variables remain unchanged and the new binary variable is appended at the end of the dataset.
Can I create binary variables in Excel files?
Yes. XLSX and XLS files are supported in addition to CSV.
Is this similar to creating variables in SPSS?
Yes. It follows the same general idea of creating a new variable from logical conditions while preserving the original variables.
Is my dataset uploaded to a server?
No. Processing takes place locally in your browser.