I am very new to writing programs in Stata. My current project is to write an ado-file to get the mean of a variable conditional on a time period (I know this is already possible with built in commands).
I have the following dataset and want to calculate the mean price for a specified time period.
Code:
year price 2002 20 2003 21 2004 19 2005 18 2006 21 2007 22 2008 20 2009 21
What I cannot figure out is how to get the if-condition into the program.
The basic version from where I started is:
Code:
cap program drop pmean program pmean, rclass version 15 syntax varlist [if] [in] qui sum `1' return list end
Thank you for your help
Kind regards
Magnus
0 Response to How to include conditions in program (.ado file)
Post a Comment