For Economist (Private Sector / Consulting)s ·
What you'll accomplish
Inherited Stata, R and Python code arrives with few comments and some that no longer match the lines below them. A Gem keeps one set of standing instructions, so every time you paste a block of code you get the same output: a plain-terms walk through each block, comments you can paste back into the file and a list of lines that may not do what the comment says.
The Gem explains code. It never asks for data, never picks or changes a model, and never runs anything for you. You read every line and run the code yourself, on a synthetic file first.
Note: Google's help page says existing Gems are recreated as skills automatically when Gems go away, starting November 2026 for personal Google Accounts and March 2027 for Workspace business, enterprise and non-profit accounts.
What you'll need
Data caution. Paste code only, never data. Client data, documents produced in litigation, anything under a protective order or NDA, and non-public company data stay in your firm's approved systems. Code can carry client information too: file paths, variable names, comments and hard-coded values. Replace those with placeholders such as "[Client]", "firm_id" or "Market 1" before you paste, and check your firm's policy on putting client-specific code into Gemini. Then look at Gemini's activity and data settings for whether chats are saved or used to improve Google's models, and for how long they are kept.
What you should see: A form with fields for a name, a description and instructions. Troubleshooting: If you cannot find Gems, your account may not include them, or your admin may have turned them off. Ask IT.
Code explainer.Explains pasted Stata, R or Python code in plain terms. Never asks for data.What you should see: The name and description filled in. Troubleshooting: Keep the name short so you can find it in the sidebar later.
Paste the block below into the instructions field.
You explain code for an applied economist. The user pastes a block of Stata, R or Python code with no data.
For every block of code the user pastes, do these things in order:
1. Name the language and say in one sentence what the block does overall.
2. Walk through the code in blocks of one to five lines. For each block, say in plain terms what the lines do, one block at a time.
3. Give the code back with a short comment above each block. Do not change any line of code.
4. Add a section called "Lines that may not behave as described". List each line where the behavior could differ from what a reader would assume, or from what a comment says. Examples: a lag function that takes the previous row and not the previous year, a merge that can duplicate rows, a missing value that is dropped without notice, integer division, a sort that changes row order. For each item, say what to check, and do not say the code is wrong unless the code itself shows it.
5. End with the line "Explanation only. Run the code on a synthetic file and read every line before relying on it."
Never do any of these:
- Never ask for data, and tell the user not to paste any if they do.
- Never choose, change, recommend or defend a statistical or econometric model.
- Never state a result, a coefficient or a number that the code would produce.
- Never claim you ran the code.
- If part of the code is unclear, say what is unclear and ask the user what the line is meant to do.
What you should see: An empty chat with your Gem's name at the top. Troubleshooting: If the Gem does not follow the rules in the first reply, check that the instructions saved in full.
Paste the snippet below. It is invented, and the file named in it does not exist.
* practice_panel.dta is invented
use practice_panel, clear
xtset firm_id year
gen growth = sales / L.sales - 1
summarize growth
What you should see: A plain-terms walk through five short blocks. The Gem should say that xtset firm_id year declares a panel with firm_id as the unit and year as the time variable. It should also say that L.sales is the value of sales one period earlier in the time variable, so a firm with no row for the previous year gets a missing value for growth, and that summarize growth summarizes the non-missing values.
Troubleshooting: If the Gem says L.sales is "the previous row", correct it in the chat. Stata's lag operator works on the time variable set by xtset, not on row position.
Paste this invented R snippet next.
library(dplyr)
panel <- read.csv("practice_panel.csv")
panel <- panel %>%
group_by(firm_id) %>%
arrange(year) %>%
mutate(growth = sales / lag(sales) - 1)
What you should see: A walk through the read, the grouping, the sort and the growth line. In "Lines that may not behave as described", the Gem should flag lag(sales): in dplyr it takes the previous row within the group, not the previous year. If a firm has a gap year, the growth for the row after the gap is computed against the earlier year and looks like a one-year growth.
Troubleshooting: If the Gem misses the lag point, ask: "Does lag() here check that the previous row is exactly one year earlier?"
You can see the difference between the two snippets yourself.
What you should see: Two different answers for 2024 on the same file. The Gem's flag was right, and the R code needs a check. Troubleshooting: If your results differ, print the data after sorting and look at the year column row by row.
What you should see: Your file with comments you have checked. Troubleshooting: If a comment is wrong, fix it in your file and tell the Gem in the chat, so you can see whether it corrects its explanation.
Explain a short block
Explain this [Stata, R or Python] code. It has no data and no client names.
[Paste the code]
Check a comment against the code
Here is a code block and the comment above it. Say whether the code does what the comment says. If it may not, name the line and what to check.
[Paste the comment and the code]
Compare two versions
What you should see: The instructions in the field. Troubleshooting: Google's guidance for writing skills advises focusing instructions on the unique guidelines for the task and including examples of the expected output. If your first outputs wander, shorten the instructions rather than adding more rules.
Here are two versions of the same step, one in [language 1] and one in [language 2]. List each place where they may behave differently, such as missing values, row order or the handling of gaps. Do not say which is right.
[Paste both blocks]
Ask what a line is for
In this code, what are the inputs and the outputs of the line below, in plain terms? If you cannot tell, say what you need to know.
[Paste the line and a few lines around it]