Long time Stata user, relatively new to writing Stata programs.
I'm trying to write a new program (something trivial for the purposes of practice) and I am having difficulty getting off the ground.
When setting up the 'syntax' line of the program, I want the program to accept two numeric variables only, that will be used for other tasks through the program...
For example:
program define example
syntax varlist(min=2 max=2 numeric) [if] [in] , [...]
This will meet my first requirement of exactly two variables needed for program, however, I want to be able to refer to the variables specifically moving forward with the program, treating one variable as 'y-variable' and one as the 'x-variable'. I imagine there is a simple way to do this but I can't figure it out.
In other words, when a varlist is provided with a command, how am I able to reference the first or second variable specifically when doing other tasks?
Any help is appreciated. Thanks.
I'm trying to write a new program (something trivial for the purposes of practice) and I am having difficulty getting off the ground.
When setting up the 'syntax' line of the program, I want the program to accept two numeric variables only, that will be used for other tasks through the program...
For example:
program define example
syntax varlist(min=2 max=2 numeric) [if] [in] , [...]
This will meet my first requirement of exactly two variables needed for program, however, I want to be able to refer to the variables specifically moving forward with the program, treating one variable as 'y-variable' and one as the 'x-variable'. I imagine there is a simple way to do this but I can't figure it out.
In other words, when a varlist is provided with a command, how am I able to reference the first or second variable specifically when doing other tasks?
Any help is appreciated. Thanks.
Comment