# Coding in Older Versions of Q

This page refers to the process of coding open-ended Text data in older versions of Q (earlier than Q5.9). If you are on a newer version of Q, please refer to Coding

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.

## Coding guides

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

## Types of Coding

Before you can start coding 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

### Classifying under only one code

If you selected Pick One (Each response can be classified under only one code) when creating your new code frame, the following steps will allow you to classify responses:

• Begin with the highlighted response, otherwise click on the response you wish to code from the list of responses. The entire selected response will appear in the grey text box above.
• Click on the code or subcode which you want to classify your response under. The response will then be placed under that code. Q provides a tally of the number of text responses that have been placed under each code, as well as a percentage showing what proportion of all responses have been placed under each code. These include any duplicate responses, however you only need to classify each unique response once, due to Q’s automatic coding process of very similar responses.
• 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.
• 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.
• Click OK to exit the coding dialog box and return to the Variables and Questions tab. Note that a new Pick One question has been created.

### Classifying under multiple codes

If you selected Pick Any (Each response can be classified under multiple codes), responses can be classified as follows:

• Click on the text response to be coded (this will then be highlighted in blue). This response will also appear in the grey text box at the top of the screen.
• Click on the code(s) or subcode(s) which you want to classify your response under. The codes selected will be highlighted. To deselect a code, simply click on it again so that it is no longer highlighted. Click the Complete button, which is located at the bottom-right of the grey text box. Q provides a tally of the number of text responses that have been placed under each code, as well as a percentage showing what proportion of all responses have been placed under each code. These include any duplicate responses, however you only need to classify each unique response once, due to Q’s automatic coding process of very similar responses.
• Continue to classify the remaining responses and create or edit codes as necessary.
• Click OK to exit the coding interface and return to the Variables and Questions tab. Note that a new Pick Any question has been created.

## 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.

## Find and classify multiple responses

Q also has a Find function that enables you to search for keywords and simultaneously code all responses that match the sequence you have typed under the same codes. As is shown below, type your keyword or phrase into the Find box, and all responses that match your search will be highlighted. Once highlighted, these responses may be classified under the same codes or subcodes by clicking on the appropriate codes.

## Reclassifying responses

You can view all of the responses that have been put into a particular code by using the drop-down menu 'Show responses from drop-down menu:

If you have misclassified a response and want to move it to another code, 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, you will need to deselect the incorrect codes in the code frame by clicking on them, before selecting the correct codes under which the response should be classified. Click Complete to reclassify the response under the selected codes.

Responses can be subclassified by creating codes under an existing code. To do this, right click on an existing code and select Add Subcode. Give the subcode a name and press Enter.

Subcodes can be deleted by right-clicking on a subcode 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 subcode of the same main code. Right-clicking on the main code will give you the option to Delete All Subcodes, and Q will automatically reclassify all responses within the deleted subcodes into the main code.

## 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.

## Import/Export Code Frame

Q also has a clipboard feature that enables you to import and export code frames. This can be done by right-clicking anywhere in the white code frame box and selecting Import/Export Code Names from the context menu. A box will appear into which you can type your code frame (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 dialog box. To apply the code frame in a new project:

• Press the Export button from within the coding dialog box. This will create a Q Code Frames *.QCodes file. This file both contains names of the codes in the code frame as well as all the rules regarding which responses should be recoded.
• Open the other project, right-click on the text variable to be coded and select Insert Variable(s) > Code Text > New Code Frame and choose the appropriate type of code frame.
• 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, select the question at Back code with. 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 UNCODED is selected at Show responses from, and scan down the list of uncoded responses below.
3. Your code frame is on the right hand side of the screen. You can see "UNCODED", "Missing Data" and "New code", which has been added for you as an example code. Right click on "New code" and select Rename. Enter the name of your first code and hit Enter.
4. Continue to construct a rough code frame by clicking the New Code button for each new code, then enter its name and hit Enter.
5. In the list of uncoded responses, select a code by clicking on it. Observe that the entire response appears in the top box. This is the response you are coding.
6. If it should be classified as a missing value then click the "Missing Data" code.
7. Otherwise click on the code (or codes) that this response fits in. If this is a multiple-response code frame then you must click Complete to finish each response.
8. Each response you code 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 code and tick Is Other/Specify. The original responses for the Other/Specify option will be deducted as you code the text responses.
3. The number next to each uncoded response indicates how many respondents gave that exact response. (Leading and trailing spaces and upper/lower case are ignored.)
4. The numbers that appear next to each code denote the number of matching responses and the percentage of all non-empty responses. e.g. "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.
1. If you have misclassified a response then select the code you used at Show responses from. Click on the response in the list and then click the "UNCODED" code. Reselect "UNCODED" at Show responses from and try again.
2. You can sub-classify codes by creating codes under each other. To do this, right click on a node and select Add Subcode.
3. You can reorder codes by dragging and dropping them.
4. To change the text variables being coded click on Input Variables. Use this to temporarily include variables from other questions if you want to construct your code frame using a larger set of responses.
5. Hold down the Ctrl key while clicking to select multiple responses.
6. Use Find to automatically select all responses that match what you enter.
7. If you want to alphabetically sort the list of uncoded responses then right click on the list and select Sort.
8. If you want to reclassify responses from one code to another without affecting any other codes they are assigned to:
1. select the old code in Show responses from,
2. select the responses that need to be changed,# right click on the selected responses, and# select Copy or Move from the popup menu and then select the new code.