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: RE: Defining input and output variables when calling a program


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: Defining input and output variables when calling a program
Date   Wed, 16 Feb 2011 14:21:53 +0000

This isn't impossible, but first let's explore another possibility. 

How do you feel about the syntax 

svendsational varlist, Generate(newvarlist) 

? -- because that's relatively easy. 

Nick 
[email protected] 

Svend Juul

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?

*
*   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