How you can use ChatGPT to analyze data in SPSS

June 15, 2023

To say that artificial intelligence tools such as ChatGPT are revolutionizing the way we work is an understatement. Since ChatGPT was unleashed to us, people have been using the AI to help with everything from crafting the next viral meme to writing the next software program. Can the Chatbot from OpenAI be used to help in analyzing and interpreting research data in SPSS? The answer is yes, and in the following video, I demonstrate to you the steps you can go through to do just that.

1. Provide enough context

Understanding your data is key to any analysis, and this is where ChatGPT shines. You can provide the AI with context about your data in several ways, such as explaining your research or sharing a few rows of your dataset, but arguably the most effective method is through a codebook. A codebook, which contains information about the variables in your dataset, enables ChatGPT to comprehend the structure of your data and provide valuable insights.

For example, I gave ChatGPT context in the form of a codebook for a fictional dataset on the nutrition of under-5 children. You can download the data file here.

The following is a codebook for a dataset on the nutrition of under 5 children. Read and understand as I will need your help analyzing the data using SPSS version 21

Variable name	Label	Values
ID	Case ID	Numbers from 1 to 413
hmi	Household monthly income	US Dollars
phe	Parents Highest Education	1=No education, 2= Primary, 3=Secondary, 4=Tertiary
cbw	Child birth weight	Number of Kgs
s	Child Sex	1=Male, 2=Female
cam	Child age	Number of months

And ChatGPT responded by saying:

2. Get data analysis insights from ChatGPT

One of the most challenging steps when analyzing data is knowing what kind of insights can be extracted from the dataset. This requires great creativity, problem-solving and analytical skills. With ChatGPT as our creative helper, all we have to do is ask.

What insights can I extract from the dataset?

From my child nutrition dataset, this is part of what ChatGPT said:

3. Get the steps for running the analyses in SPSS

The insights that SPSS will give to you will most probably be general, without necessarily mentioning the SPSS procedure you can use and the steps to run the procedure. But that’s not a problem because we can ask ChatGPT to give us all that information.

So, for example, I said:

Give me the steps for running the descriptive statistics in point number 1

ChatGPT is the king (or queen?) of context. Just with that, it gave me all the steps I needed to run the analysis. At this point, it is important to know that the AI may not get it all right. Especially if you are using GPT-3.5 which is the default model available on free ChatGPT accounts. So, it’s always important to nudge it in the right direction when you realize that it is hallucinating.

Here is part of what it said:

Some of the steps were not necessary since I already had my data ready and open in SPSS. So, I went straight to step 4. After doing these steps, I got my analysis output which I copied – ready for the next step.

4. Get help with interpretation and analysis

Beyond providing suggestions for analysis, ChatGPT can assist with the interpretation of results and even guide you in reporting these in APA format – a standard style in academic writing. This can be especially beneficial for those writing research papers or reports.

I followed-up the conversation with the following:

Here is the output from the analysis:

Statistics				
		Household monthly income	Child Birth Weight	Child age in months
N	Valid	413	413	413
	Missing	0	0	0
Mean		203.39	2.8089	18.67
Median		180.00	2.8400	18.00
Std. Deviation		104.131	.39204	9.650

Write interpretation and report it in APA format

From which the AI went ahead and gave me the following interpretation of the output:

Again, it is important to make sure that you have reviewed the information before you can simply copy and paste the output to your thesis or report.

Bonus step: Go straight to SPSS syntax

Perhaps one of the most exciting features of this AI-assisted data analysis is the ability of ChatGPT to generate SPSS syntax for complex analyses. This means that you can bypass the usual navigation through menus and dialog boxes in SPSS and instead, simply copy and paste the provided syntax.

For example, still within the context of the child nutrition data analysis, I asked the following:

Write the SPSS syntax for ANOVA between phe and cbw

Of which ChatGPT gave me the following:

So, instead of going through the SPSS graphical user interface to run the analysis, I just went to File -> New -> Syntax. Then I pasted the code, selected all of it in the SPSS syntax editor, and finally clicked the big green play button on the toolbar.

You will notice that ChatGPT gave me code for a univariate analysis of Variance. If I needed the One-Way ANOVA instead, all I needed to do is just add that information in my prompt.

It is quite common to get errors when you run code suggested by ChatGPT. When you do, you can paste the error to ChatGPT where it will revise the code for something that might work.

You can view the full ChatGPT conversation here.

Conclusion

The integration of ChatGPT with data analysis in SPSS is a powerful combination that allows for more efficient and effective data analysis. By harnessing the power of AI, you can draw insights faster, making your research process significantly more streamlined. It’s clear that artificial intelligence is not just the future of data analysis – it’s already here, and the time to start utilizing it is now.

Learn SPSS, STATA, KoboToolbox, Power BI and more

Join DATAFORDEV for self-paced courses, live online workshops, and a private community forum for social impact professionals.

Join now