The precise steps required to use a data file that contains no or limited metadata, such as Excel files, CSV files and SQL databases, will depend upon how it has been created. It is generally difficult-to-impossible to correctly set up a CSV or Excel file without both access to the questionnaire and access to the person who exported the CSV file. Further, the process will be much easier if the file has been created in accordance with the Excel and CSV Data File Specifications (and better yet if in a better file different format).
Setting up a CSV or Excel File
- Select File > New Project.
- Select File > Data Sets > Add to Project > From File.
- After answering the next prompt, copy the variable labels from their source file and then go back to Q (generally this is best done using Excel; Q requires that each variable label be in a separate line).
- In the Variables and Questions tab, click on row 1 of the Label column.
- Using the scroll bar, go to the last row in the Variables and Questions tab. Hold down your Shift key and click on the last cell in the Label column. Your Label column should now be highlighted.
- From the Edit menu, select Paste Labels.
- Select all the variables with the same code frame and press the Values button (). To select variables from one contiguous group, click on the row number of the first variable, hold down the Shift key, and click on the row number of the last variable. To also select data from a non-contiguous group of variables, hold down the Ctrl key and click on the next group of variables.
- Type in the correct value labels (e.g., 0 = Not selected and 1 = Selected). Alternatively, paste the labels in. (It can be helpful to first copy from within Q and then paste into Excel to appreciate the format that Q anticipates for the labels.)
- Click on the button for each of the remaining variables and enter the correct value labels.
- Select the rows that correspond to the first multiple-response question. Right-click and select Set Question. Ensure that the question type and name of the question are correct. Click OK.
- Click on to view the Value Attributes dialog box, so you can check that the correct values are being counted.
- Repeat this process for all the questions in the file.
Setting up when all the variables are Text
Sometimes CSV files contain all text. For example, rather than recording, say, a 1 for male the file instead contains Male. In such instances, the first things to be done are to:
- Select all the variables with a Variable Type of Text. (If the text variables are interspersed with other variables, you will need to do these steps for each set of adjacent text variables.)
- Change the Variable Type (e.g., to Categorical if that is appropriate).
- Press , which will group together all the categorical variables (the purpose of this button is to move all the variables up 1; in this instance, the button is pressed because as a by-product it puts all the variables together.)
- Re-select all the text variables and press .
- Select Tools > Save Data as SPSS/CSV File and save it as a .sav file.
- Import the newly-created file as a new data file.
Setting up an SQL database
When importing an SQL Database, you need to follow all the steps described above for a CSV file.
In the current version of Q, you can select File > Data Sets > Add to Project > From Database (SQL). However, the process for importing the data is slightly different in older versions of Q. You need to first import another data file and then add the SQL database using Add Data File To Project, after which you can delete the initial file. See How to Import Data from SQL for more information.
How to Use Excel and CSV Files in Q
Article is closed for comments.