Skip to main content

Create Variable – VTL

Learn about the 'VTL' feature, which handles complex and extensive variable processing tasks at once through text commands.

Updated today

What Is VTL?

VTL stands for Variable Transform Language, and it is Opensurvey's working language used when processing multiple variables or creating new variables.

In general, data transformation tasks such as recode, variable combination, and formula calculation can also be configured by clicking buttons on screen. However, when there are many variables or the logic becomes complex, configuring them one by one on screen can be time-consuming or difficult to manage.

In these situations, using VTL lets you enter text commands to process multiple tasks at once.

When Do You Need VTL?

When you need to apply the same operation to multiple variables repeatedly

"There are so many variables that it's too tedious to set up recodes and calculations one by one. Is there a way to process them all at once? 🤔"

🧙 Here's how you can use it

Using VTL, you can apply the same recode or calculation to multiple variables at once.

For example, when you need to recode response values from multiple questions according to the same criteria, entering VTL instead of configuring each variable individually lets you process the repetitive work quickly.

This allows you to efficiently handle tasks involving many variables and greatly reduce the time required.

When the logic for variable combination or calculation is complex

"I want to create a new variable by combining multiple conditions, but the setup is too complex. Can it be handled more easily? 🤔"

🧙 Here's how you can use it

Using VTL, you can combine conditions from multiple variables or apply formulas to handle even complex logic at once. For example, you can group responses from multiple questions by condition to create a new variable, or configure it so values are only calculated when specific conditions are met.


How to Create Variables with VTL

📌 The create variable feature is available on the Professional or Enterprise plan.

1️⃣ Enter variables on the VTL screen.

step 1. Click [Variables] at the top of the Analytics screen, then select [Create variable > VTL] from the left menu.

step 2. Enter the name, label, and variable type for the variable to be created.

✅ New variable name: Enter the name of the variable to be created. Variable names can use English letters, numbers, and some special characters (_, -, ., (), ~, {}, [], +).

✅ New variable label: Enter the label for the variable to be created. It is a good idea to write a name that clearly conveys the meaning of the combined data. (Example) If you combined respondents where gender is 'Female' and age is 'in their 20s' → "Women in their 20s"

✅ New variable type: Select how to designate the variable type to be newly created through VTL operations.

2️⃣ Enter VTL commands.

step 1. In the 'New variable VTL' input field, enter the VTL commands to use for the variable being created. If you're curious about VTL grammar or the language system, please refer to the document below.

💡 Usage tip | Clicking the [Load VTL] button shows a list of previously created variables, and you can load previously written VTL to reuse it.

💡 Usage tip | You can copy and paste the VTL examples provided at the bottom of the screen, then modify only the variables or values.

3️⃣ Enter value labels.

step 1. Once the new variable information and VTL input are complete, the [Enter value labels] button becomes active. Clicking the button shows the 'New value label' screen.

step 2. Enter the value labels for the variable to be created. To add more values, click the [+ Add value] button to enter new values.

💡 Usage tip | Clicking the [Load value labels] button lets you load values from an existing variable and edit them for use. However, if the new variable has fewer values than the existing variable, only up to the currently created values can be loaded.

💡 Usage tip | Clicking the [Reset] button lets you delete all content entered in the value labels.

step 3. If needed, click the [Set as Other] button to select which values among those created to process as 'Other.'

💡 Usage tip | To remove a value that has already been designated as Other, click the [Remove from Other] button.

5️⃣ Create the new variable.

step 1. Click the [Create variable] button in the upper right.

step 2. Check the settings in the 'New variable preview' screen, then click [Done] to complete variable creation.

step 3. Variables created with VTL can be viewed in the 'Variable list' and can also be used in the 'Results tab,' 'Cross-tab tab,' and 'Report tab' of Analytics.

💡 VTL has even more features available.

If you want to edit the VTL after entering it and navigating to the value label input screen, click the [Edit] button in the new variable VTL area.

Clicking the button returns you to the initial screen with the variable name, label, type, and VTL content you previously entered all preserved, so you can edit only the necessary parts without needing to enter everything again from scratch.


Did this help you understand how to use the VTL feature?

If you still have questions after reviewing the guide, please contact us anytime via the [Customer Support icon] in the bottom right corner of your screen. Our team will do its best to help you resolve any difficulties you're experiencing.

Did this answer your question?