I am in the process of replicating the Stata code of some researchers. The code snippet below is from the very beginning of the do file provided by the researchers. In the code, FactorBetasStartFile is a dta file that is being read into memory. It contains a variable called FirmGroup.

To give an idea of the dta file, it looks something like this:

Date ; Company_ID ; Returns ; FirmGroup
31MAR2003 ; 10001 ; 500 ; 1
30JUN2006 ; 10001 ; 400 ; 1
31MAR2003 ; 20001 ; 900 ; 2
30JUN2006 ; 20001 ; 300 ; 2

So, a given company has some data over a range of dates. The data is sorted by Company_ID and date. And, the FirmGroup variable increases by one each time we have cycled through the range of dates for a given company. I have attached the first few rows of data of the dta file in an Excel file.

When I run the code below, I get an invalid syntax error when trying to execute the last line of the code (keep if FirmGroup == `FirmGroupNum'). Any idea on why this might be happening?

Code:
args FirmGroupNum

clear
set more off

use FactorBetasStartFile, clear

keep if FirmGroup == `FirmGroupNum'
Thanks,
Tasneem