# Category:Coding

Related Online Training modules
Coding Text Variables
Back-coding
Coding Spontaneous Awareness
Generally it is best to access online training from within Q by selecting Help : Online Training

One or more Text variables can be coded by right-clicking them in the Variables and Questions Tab and selecting one of the options under Insert Variables > Code Text. The options for coding are discussed below.

Q’s coding facilities allow you to:

• Code single response, multiple response and looped questions.
• Back-code “other specify” questions.
• Automatically recode near-identical responses. For example, once you have coded a specific text response, such as Coce as Coke, Q will automatically recode any other responses using the same spelling into Coke, even if they use different punctuation, capitalization or spaces.
• Import and export code frames. This imports both the names of the codes and the rules about which text responses go in which code names.

If your Text variables contain data that is really categorical in the sense that the number of unique responses is relatively small then it is simpler to convert them to categorical variables using the method that is outlined on the page How to Automatically Code Text Variables. This is often the case when working with CSV or Excel data files.

This page outlines the process for coding in Q5.9 and later. If you are on an earlier version of Q, please refer to Coding in Older Versions of Q

## Coding guides

For step-by-step guides on coding, check out these articles from our blog:

## Types of Coding

The first choice when selecting Insert Variable(s) > Code Text is to decide if you want to use our legacy coding module (New Code Frame (Legacy)) or if you want to use our new, updated coding module which integrates with our advanced semi-automatic coding features. This latter option has a sub-selection where you can choose between Manual or Automatic categorization, however you can access the same functions from both these options.

Finally, you must choose whether you want to assign each response to a single code or multiple codes. This choice affects the output question as shown in the table below.

One code per response Multiple codes per response
One input text question Pick One Pick Any
Multiple input text questions Pick One - Multi Pick Any - Grid

Note that the legacy coding function is likely to be removed in a future release of Q. The remainder of this documentation will consequently detail the new coding functions.

## The Coding Interface

The coding interface consists of three main panes, and three sets of drop-down boxes and selection tools. Starting at the top left, the first drop-down, labelled Show responses from will allow you to select codes/categories that have already been constructed, and will then filter the responses to those that have been categorized into the selected category. The pane below that will show the selected response. Continuing down, a series of sorting and finding tools are available. The large pane below the sorting and finding tools contains a list of all the responses in the selected category. Selecting UNCATEGORIZED in the Show responses from drop-down, will show all responses that have not been classified. The pane on the right-hand side of the screen is where you create categories/codes, and where you select what to assign each response to. Below, at the very bottom of the interface, are functions to Import and Export your code frames to other questions or Q projects, and options for conducting back coding into existing categorical questions.

## Creating Categories/Codes

The first thing to do when coding is to create a category to assign a response to (unless you're back-coding, in which case you'll have some options already: see below). By default, when you start a new code frame, Q will have two codes available already. Missing Data is a code to assign any responses to that you effectively want to remove from your final question. New Category is a code with a default label. Let's change this.

1. Right-click the code New Category
2. Select Rename Category
3. Give the category a new name, then click OK

To add more categories to your code frame, right-click in the categories pane and select Add New Category. You'll then be asked to specify the name/label. Do so, then click OK to create the category.

Any codes that exactly match the code label you've typed in will be automatically and instantly coded into that category.

### Deleting a Category

Right-click the category in the categories pane and select Delete Category. You cannot delete a category that has responses assigned to it. In order to delete a category with responses assigned, you will first need to re-assign those responses into other categories, or put them back into UNCATEGORIZED. To do so:

1. In the category drop-down at the top-left of the coding interface, select the category you would like to delete.
2. In the responses pane, select all the responses at once.
3. Assign the responses into the appropriate (other) code, or to UNCATEGORIZED (steps here will vary depending on whether you're coding into Mutually Exclusive Categories or Multiple Overlapping Categories (see below).
4. Once no responses are assigned to the category you want to delete, right-click the category and select Delete Category

Next to your text code label you will see some numbers. The percentage shows what proportion of all responses have been placed under each code. Next, you can see the number of unique responses have been classified into that category. The final number is the count of respondents that have been allocated to the category.

As an example "19% 50 n=55" indicates that:

• 19% of respondents who entered anything, entered text matching this code.
• 50 distinct text responses match this code.
• 55 respondents match this code. This implies that 5 (55 - 50) of the responses are duplicates. For example, if two respondents said "I like it" then you only need to classify this phrase once, but both responses will be counted.

## How to Classify a Response Under Only One Code/Category

Coding into Mutually Exclusive Categories means coding each provided text response into only one code/category. This is typically used when respondents have been asked to list brands or given only very short, specific answers, or when you want to restrict the coding to a central core issue.

To classify a response into a category:

1. In the responses pane, select the response(s) you wish to code. The entire selected response will appear in the text box above all the responses. If you select multiple responses then it'll say how many you've selected.
2. Click on the code/category which you want to classify your response under in the categories pane. The response will then be placed under that code.
3. The next unclassified response will move up and you can continue to code the remaining responses by repeating the previous step until all responses have been placed into a code.
4. You can continue to rename existing codes and create new codes and subcodes at any time by right-clicking on the codes and selecting the appropriate option from the context menu.
5. Click Save Categories to exit the coding dialog box and return to the Variables and Questions tab. Note that a new Pick One question has been created, which contains your coded data.

## How to Classify a Response Under Multiple Codes/Categories

Coding into Multiple Overlapping Categories means coding each provided text response into one or more codes/categories. This is typically used when respondents have provided longer or fuller text answers to a question.

To classify a response into multiple categories:

1. In the responses pane, select the response(s) you wish to code. The entire selected response will appear in the text box above all the responses. If you select multiple responses then it'll say how many you've selected.
2. Click on the code/category which you want to classify your response(s) under. The codes selected will be highlighted. To deselect a code, click on it again so that it is no longer highlighted.
3. Click the Categorize as button to categorize the responses (for which to select, see below).
4. Continue to classify the remaining responses and create or edit codes as necessary.
5. Click Save Categories to exit the coding interface and return to the Variables and Questions tab. Note that a new Pick Any question has been created.

### Categorize as

This button will be available when you select responses that haven't been placed into a category already (i.e. that's UNCATEGORIZED). It will categorize the responses into the selected code(s).

### Move to

When coding into multiple categories, and the selected response(s) have already been coded into one or more categories, the Move to button will take the selected responses and place them into the selected categories. If these responses have been previously classified into one or more other categories, then they will be removed from those categories.

When coding into multiple categories, and the selected response(s) have already been coded into one or more categories, the Add to button will take the selected responses and place them into the selected categories. If these responses have been previously classified into one or more other categories, then they will remain in those categories, and simply be added into the currently selected categories.

### Remove From

Remove From allows you to remove the selected responses from the selected categories. If, following this action, a response is no longer present in any category, then it will be classified as UNCATEGORIZED

## Automatic coding of very similar responses

Q automatically classifies duplicate responses. For example, if three respondents give the same (or almost exactly the same) response, you only need to classify the phrase the first time it appears in the list, as Q will automatically search for and classify the other two responses into the same code. This function is not case sensitive (so it ignores capitalization) and will automatically delete spaces in front of and after the response.

## Semi-Automatic Categorization, Sorting, and Finding

### Find

Finding is the most basic form of locating responses in your data that contain a specific search term. Type a word into the Find field, and all responses that contain that term will be highlighted. You can then either code all of them at once to your corresponding category, or click the > or < to go between the found responses so that you can classify each of the independently of one another.

### Sort by

The sorting functions range from the simple, to the super-advanced.

• Sort by > Data file order will sort your data in the same order as the records in your data file.
• Sort by > Alphabetically will sort your data in alphabetical order.
• Sort by > Number of responses will sort the text responses in order of most to least mentioned.
• For Sort by > Fuzzy Match and Sort by > Similarity to [category], see below.

### Fuzzy Match

Sort by > Fuzzy Match will allow you to specify a term or phrase in the Fuzzy sort on field. Q will then process your data and work out which responses most closely match the phrase or term. This will return the responses sorted by how well they match the search term or phrase. Next to each response you will see an orange bar that represents how well the term or phrase is represented within each response. In the screenshot below, you can see that the bar narrows a little as the match is less certain the more different the text responses are.

1. Select Sort by > Fuzzy match
2. In the Fuzzy sort on field, type in your term or phrase.
3. Click Sort now

### Similarity to [category]

Sort by > Similarity to [category] will allow you to select one of your existing categories that have some data categorized already. Using this function will then go through all your data and work out which responses most closely match the category. It does this by working out what appears to match the responses that have already been coded, and then orders the remaining responses in order of how similar they are to the data that's already been categorized.

## Reclassifying responses

If you have misclassified a response and want to move it to another category, select the code you used from the Show responses from: drop-down. If classifying under a single code, find and select the response you wish to reclassify in the list, then click on the correct code to reclassify the response. If classifying under multiple codes, make sure to use the Move to or Add to button when categorizing as this will move the responses from one set of categories to the selected set of categories.

Responses can be subclassified by creating categories under an existing category. To do this, right click on an existing code and select Add Subcategory. Give the subcategory a name and click OK.

Subcategories can be deleted by right-clicking on a subcategory and selecting Delete. If you choose to delete a subcode that contains responses, you will be given the option to Delete and Reclassify as. This function allows you to reclassify the coded responses into another subcategory of the same main code. Right-clicking on the main category will give you the option to Delete All Subcategories, and Q will automatically reclassify all responses within the deleted subcategories into the main category.

## Back coding

The back coding function enables you to code text responses using an existing question. See How to Back Code Other Specify Responses for more information.

## Reusing a code frame

It is also possible to reuse a code frame that has been created to code another Text Variable. This option is selected by right-clicking on the row number of text question in the Variables and Questions tab, then selecting Insert Variable(s) > Code Text. Click on the code frame to be reused and the coding interface will open, revealing the previously used code frame. Any responses that exist in the new text question that match the responses in the original question used for coding will be automatically coded.

## Import/Export Category Names

Q also has a clipboard feature that enables you to import and export category names. This can be done by right-clicking anywhere in the white code frame box and selecting Import/Export Category Names from the context menu. A box will appear into which you can type your category name(s) (see below). Alternatively, you can paste an existing code frame into the box (by right-clicking and selecting Paste from the context menu). The codes you enter will replace the existing codes in your code frame in the order entered.

If you wish to create sub-codes, do this using tabs:

Main code
Sub code


## Sharing coding across projects

Coding can be shared between projects by using the Import and Export buttons on the bottom-left of the coding interface. To apply the code frame in a new project:

• Press the Export button from within the coding interface. This will create a *.QCodes file. This file contains names of the codes in the code frame, and the rules regarding which responses should be coded to which categories.
• Open the other Q project, right-click on the text variable to be coded and select Insert Variable(s) > Code Text > New Code Frame. It's important to select the same type of destination question. If the .QCodes file you're importing comes from a Mutually Exclusive Categories question, then you must select Mutually Exclusive Categories in this second project too. The same goes for Multiple Overlapping Categories.
• Press the Import button, select the file an press OK.

## How to Code

You must already have selected the text question(s) you want to code. Coding will produce a new question with the results of your coding.

1. Do you need to "back code" against another question? If so, in the coding interface, select the question under Inputs and Back Coding.... You typically use this when you are coding the responses for an Other/Specify question and want to combine the coded answers with the original question. Note that you can only select Pick One questions here if you have ticked Only one code per respondent, and you can only select Pick Any questions here otherwise. (If you have multiple input questions then you can assign back code questions to them each via the Inputs and Back Coding button.)
2. Observe that UNCATEGORIZED is selected at Show responses from, and scan down the list of UNCATEGORIZED responses below.
3. Construct categories by clicking the New Category button for each new category, then enter its name and click OK.
4. In the list of UNCATEGORIZED responses, select a category by clicking on it. Observe that the entire response appears in the top box. This is the response you are categorizing.
5. If it should be classified as a missing value then click the "Missing Data" category.
6. Otherwise click on the category(-ies) that this response fits in. If this is a multiple-response code frame then you must click Categorize as to finish each response.
7. Each response you categorize will disappear from the list and the next response will appear, ready for coding.

## Notes

1. If you make a mistake press Ctrl + Z to undo your last action. Ctrl + Y will redo actions.
2. If you are back coding with a Pick Any question that includes an Other/Specify response, right click on the corresponding category and tick Is Other/Specify. The original responses for the Other/Specify option will be deducted as you categorize the text responses.
3. You can reorder categories by dragging and dropping them.
4. To change the text variables being categorized click on Input Variables. Use this to temporarily include variables from other questions if you want to work with a larger set of responses.
5. Hold down the Ctrl key while clicking to select multiple responses.

## Pages in category ‘Coding’

The following 9 pages are in this category, out of 9 total.