Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Aaron Kirkman <ak1795mailserv@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Why does Stata return an invalid syntax error in this ado file? |

Date |
Fri, 19 Oct 2012 17:18:08 -0500 |

Dear Statalist, I'm writing a simple ado file, --statetofips--, to assign fips codes to observations based on the state name. If I run the following code, I do not receive an error: ## clear input str8 state Alabama Alabama Alabama Alaska Alaska Alaska Arizona Arizona Arizona Arkansas end gen int fips = . replace fips = 1 if lower(state) == "alabama" replace fips = 2 if lower(state) == "alaska" replace fips = 4 if lower(state) == "arizona" ## However, if I run this code, I receive an "invalid syntax" error: ## clear input str8 state Alabama Alabama Alabama Alaska Alaska Alaska Arizona Arizona Arizona Arkansas end discard statetofips state, generate(fips) ## These are the contents of --statetofips.ado--, which is located in the same directory as the above do file: ## program define statetofips syntax varname , Generate(String) if "`generate'" != "" { quietly gen int `generate' = . } replace `generate' = 1 if lower(`varlist') == "alabama" replace `generate' = 2 if lower(`varlist') == "alaska" replace `generate' = 4 if lower(`varlist') == "arizona" replace `generate' = 5 if lower(`varlist') == "arkansas" replace `generate' = 6 if lower(`varlist') == "california" end ## I reduced --statetofips.ado-- to its simplest form, and the error persists: ## program define statetofips syntax varname , Generate(String) end ## What is causing the syntax error in the ado file? Thank you, Aaron Kirkman * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Why does Stata return an invalid syntax error in this ado file?***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: Multivariate kernel regression** - Next by Date:
**Re: st: Why does Stata return an invalid syntax error in this ado file?** - Previous by thread:
**st: access information criteria after treatreg twostep** - Next by thread:
**Re: st: Why does Stata return an invalid syntax error in this ado file?** - Index(es):