Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Thursday, October 04, 2018

Stata undocumented commands and options

Stata undocumented commands and options
Stata undocumented/obsolete commands and options are usually used by limited people such as Stata programmers of StataCorp in developing Stata. However, sometimes I find they are quite handy.

Tuesday, October 02, 2018

Stata: output and reuse the estimates of histogram

Stata: Output and reuse the estimates of a histogram
Sometimes we would like to export the estimates of a histogram and make a histogram plot using other software such as Excel.  The undocumented command - twoway__ histogram_gen - can help.
  • Stata tip 20: Generating histogram bin variables, for example (modified):
    • sysuse auto,clear
    • histogram weight, percent bin(20)
    • twoway__histogram_gen weight, bin(20) percent gen (hvalue xvalue, replace)
    • twoway bar hvalue xvalue, barwidth(.15) bstyle(histogram)
    • list hvalue xvalue if !missing(hvalue), sum(hvalue) clean
    • or, you can copy columns from the "Data Editor" window and paste them into Excel sheet.
  • or use - serset -, the data in the .gph file are stored in the serset format
    • sysuse auto,clear
    • histogram weight, percent width(100)
    • preserve
    • serset use,clear
    • then, you can copy the first and third columns (such as __000001, __000003) from the "Data Editor" window and paste them into an Excel sheet.
    • restore
  • - grexport - a user-written ado file, an alternative to -graph export-
    • sysuse auto,clear
    • histogram weight, percent width(100)
    • grexport, list //list results in the result window

Saturday, July 14, 2018

Stata: Output the results into Excel tables

Stata: Output the results into Excel tables


Tuesday, February 27, 2018

SAS: LSMESTIMATE vs CONTRAST and ESTIMATE

SAS: LSMESTIMATE vs CONTRAST and ESTIMATE
LSMESTIMATE was a new statement in SAS 9.22 and much easier to be used than CONTRAST and ESTIMATE

SAS: how to customize the plots

SAS: How to Customize the Plots
    ODS GRAPHICS ON;
    ODS TRACE ON;
    ODS OUTPUT Histogram=HIST;
      PROC UNIVARIATE DATA=SAShelp.cars NOPRINT;
      VAR invoice;
      HISTOGRAM invoice;
    RUN;
    ODS TRACE OFF;
    PROC PRINT DATA=HIST;RUN;