Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Defining input and output variables when calling a program


From   Svend Juul <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Defining input and output variables when calling a program
Date   Wed, 16 Feb 2011 15:14:28 +0100

I want to develop a command (ado-file) that takes as the input the responses to a number of questions and as output generates new variables, much as the reponses to the 36 questions in the SF-36 questionnaire are used to generate 8 scales. I want the command to be flexible; the names of the input and output variables being defined when calling the program, not by modifying the program.

If the program name is xxx, the input variables are q1-q15 and the output variables s1-s5, I want to be able to call the program by something like:

  . xxx q1-q15 s1-s5

The following is not legal; apparently you cannot have both a –varlist- and a –newvarlist-:

  . syntax varlist(min=15 max=15) newvarlist(min=5 max=5)

If I combine the input and output variables in a single –varlist- I get an error message because all variables must exist in the dataset beforehand:

  . syntax varlist(min=20 max=20)

... - unless I generate the output variables (e.g., as missing) before calling the program, but that seems to me to be a clumsy solution.

Any suggestions?

Svend
________________________________________________________

Svend Juul
School of Public Health, Department of Epidemiology
Bartholins Allé 2
DK-8000 Aarhus C,  Denmark
[email protected]
_________________________________________________________


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index