0

I'm working with data from ICPSR for which a do file was written in Stata V7, around 2001. The do file notes that the program only runs in Version 7 (which is true). I'm having issues understanding parts of the code and I'm wondering if any of you more knowledgeable folks can help.

Here's an example block of the code:

program drop _all;
program define impact1;

scalar drop _all;

*First define proportions in your sample;

qui reg svy_cmove [pweight=`8'] if `1'~=. & t_exp_vs_ph==1;
scalar define ptmove=_b[_cons];

qui reg svy_cmove [pweight=`8'] if `1'~=. & t_s8_vs_ph==1;
scalar define ps8move=_b[_cons];

qui reg `6'  [pweight=`8'] if `1'~=.;
scalar define tprop=_b[_cons];

qui reg `7' [pweight=`8'] if `1'~=.;
scalar defin s8prop=_b[_cons];

*Need to svyset data to specify weight;

svyset pweight `8' ;

The code runs fine and performs what it is supposed to (replication of a table from a study), but what I don't understand is what the numbered references mean, for instance,

pweight= `8'

It refers to a total weight used in the survey, but I don't know how Stata makes the connection between the reference

`8' 

and the proper weight variable. Note that it is NOT defined at any point earlier in the do file. The code uses these references throughout the file when it runs a series of regressions to replicate the tables produced by the research team.

Any insight into how this process operates would be helpful so I can understand how Stata makes the connection between the variable and the number.

2
  • 1
    Hi, AXG, and welcome to the site! Unfortunately, this is really a Stata question, not a statistics question, and you'd almost certainly be better served on stackoverflow (the programmer site) than here (the statistics site.) Either way, it looks like a real puzzle, and I hope you find an answer somewhere.
    – jbowman
    Commented Feb 18, 2014 at 21:54
  • 3
    I agree with @jorpppp. On the evidence here there is nothing archaic about this code; it is just that how to call it is not documented here. By the way, a statement version 7 (if that is implied here) means that version 7 of Stata (or greater) is required, not that it will run only in version 7.
    – Nick Cox
    Commented Feb 18, 2014 at 22:35

1 Answer 1

3

These are just positional arguments. 1 refers to the first word written after the program command, 2 to the second and so on. This is still standard in Stata

Here's an example

clear
program define positions
    di "`1'"
    di "`2'"
    di "`3'"
end
positions one two three

Presumably when you call the impact1 program, the eighth argument is the probability weight.

2
  • Thanks, jorpppp. I scrolled down the code to where the impact1 program is called, and it says this: impact1 m_hsg_cost "$covars" "" e(N) 0 t_exp_vs_ph t_s8_vs_ph wt_Totsvy ; which would be consistent with 8 being the weight, 7 being the control, 6 being the treatment, down to 1 being the outcome variable of interest. I've never seen code written this way where the argument referenced isn't defined until later in the file; this is definitely useful to know. Thank you!!
    – AXG
    Commented Feb 19, 2014 at 1:41
  • The use of positional arguments carries over a practice good for do-files to programs. It is well documented in [U] e.g. see 16.4.1 in stata.com/manuals13/u.pdf
    – Nick Cox
    Commented Feb 19, 2014 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.