Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to access what is returned by "tab" for binary variables?

    Hello everyone,

    I would like to use
    Code:
    tab VAR
    with return list. However, tab doesn't provide the numbers I would like to access in return list.

    Here is an example which also explains what for I want to use that:
    Code:
     log close _all
    clear all // this clears data, analysis previously loaded
    set more off // this allows all results to print at once, rather than one screen at a time
    set linesize 70 // this controls width of text lines in Stata;
                    // avoid wrapping or running off page
    version 15  // sets Stata version;
                
    ************************************** Using MarkDoc & Microsoft Word
    set linesize 80
    qui log using autotest, replace smcl
    
    
    //OFF
    sysuse auto
    sum price
    return list
    //ON
    txt "Average price is" r(mean) ".
    
    //OFF
    tab foreign
    return list
    
    //ON
    txt "There are ? domestic and ? foreign cars in the dataset."
    
    qui log c
    
    markdoc name,  exp(docx)                  //docx for ms word
    (Yeah there is an error in the end. I have no idea why, but I just want to fill in X and Y. Just as with the average price.)

    As I need to do this repetitively I am interested in any shortcuts I could use here.

    Thanks in advance.
    Last edited by Gracia Brueckmann; 10 Jul 2018, 09:20.

  • #2
    You can't get that from -return list- after -tab-. The counts that -tab- calculates can be captured in a matrix by using the -matcell()- option.

    Code:
    sysuse auto, clear
    
    //OFF
    tab foreign, matcell(M)
    
    //ON
    display  "There are `=M[1,1]' domestic and `=M[2,1]' foreign cars in the dataset."
    By the way, there is no Stata txt command. Printing out results and messages is accomplished with -display-. If, perhaps, you are using some commnity-contributed command named -txt-, the Forum etiquette is to explain that, give credit to its author(s) and point out where others can get it.


    Comment


    • #3
      Thank you very much for your kind answer.

      I am sorry, that I did not know about the things you mentioned in the by the way. The txt comes from markdoc (ssc install markdoc) from E. F. Haghish.

      Thanks you so much

      Comment

      Working...
      X