[ create a new paste ] login | about

Link: http://codepad.org/AsKC79uK    [ raw code | fork ]

Plain Text, pasted on Feb 28:
{smcl}
{* *! version 1.1.3  26feb2014}{...}
{vieweralsosee "[P] collapsetofilenames" "mansection P collapsetofilenames"}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "[P] foreach" "help foreach"}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "[D] codebook" "help codebook"}{...}
{vieweralsosee "[D] inspect" "help inspect"}{...}
{vieweralsosee "[R] tabulate oneway" "help tabulate_oneway"}{...}
{viewerjumpto "Syntax" "collapsetofilenames##syntax"}{...}
{viewerjumpto "Description" "collapsetofilenames##description"}{...}
{viewerjumpto "Options" "collapsetofilenames##options"}{...}
{viewerjumpto "Remarks" "collapsetofilenames##remarks"}{...}
{viewerjumpto "Examples" "collapsetofilenames##examples"}{...}
{viewerjumpto "Saved results" "collapsetofilenames##saved_results"}{...}
{viewerjumpto "References" "collapsetofilenames##references"}{...}
{title:Title}

{p2colset 5 21 23 2}{...}
{p2col :{cmd:collapsetofile} {hline 2}}Collapses data to a file that is recoverable with {cmd:recover}{p_end}
{p2colreset}{...}

{marker syntax}{...}
{title:Syntax}

{p 8 17 2}
{cmd:collapsetofile}
{opt (stat)}
{cmd:using} {it:{help filename}}
{ifin}
[{it:aweight}]
{cmd:,} {opth by(varlist)} [{it:options}]

{p 8 17 2}
{cmd:recover}
{it:{help filename}}
[{cmd:,}
{opt clear}]

{pstd}where {it:stat} is one of

{p2colset 9 22 24 2}{...}
{p2col :{opt mean}}means{p_end}
{p2col :{opt sum}}sums{p_end}
{p2colreset}{...}

{synoptset 15 tabbed}{...}
{marker table_options}{...}
{synopthdr}
{synoptline}
{syntab :Options}
{synopt :{opth by(varlist)}}groups over which {it:stat} is to be calculated
{p_end}
{synopt :{opt cw}}casewise deletion instead of all possible observations
{p_end}
{synopt :{opt replace}}replace {it:filename} if it exists
{p_end}
{synoptline}
{p2colreset}{...}

{marker description}{...}
{title:Description}

{pstd}
{cmd:collapsetofile} is similar to {helpb collapse}, with a few differences. {p_end}
{pstd} 1) data is saved to an external mata file that may only be recovered by {cmd:recover}.
Variables are stored along with variable labels, value labels, display formats, and storage types. {p_end}
{pstd} 2) metadata is saved with the file. This includes global macros and dataset characteristics stored in _dta[{it:char}].{p_end}
{pstd} 3) collapsetofile is faster than collapse (as much as 50% faster in one test).{p_end}
{pstd} 4) data {it:must} be sorted by {it:byvars} prior to running collapsetofile.{p_end}
{pstd} 5) {opt (stat)} must be specified. {p_end}
{pstd} 6) {opt (stat)} may only be {it:mean} or {it:sum} (more could be added in a future update). {p_end}
{pstd} 7) collapsetofile {it:does not} support syntax for {it:target_var}{cmd:=}{varname} at the moment (though if desired, it could be added in a future update). 

{marker options}{...}
{title:Options}

{phang}
{opth by(varlist)} specifies the groups over which the means, etc., are to be
calculated. {it:varlist} may not refer to string variables. (Though this could
be added if desired)

{phang}
{opt cw} specifies casewise deletion.  If {opt cw} is not specified, all
possible observations are used for each calculated statistic.

{phang}
{opt replace} specifies that {it:filename} is deleted if it already exists. 
If the file already exists and replace was not specified, collapsetofile will
abort with error.


{marker remarks}{...}
{title:Remarks}

{pstd}
Please contact Andrew Maurer if you find any bugs or have suggestions for additional features

{pstd}
Written Feb 26, 2014

{marker examples}{...}
{title:Examples:}

{pstd}Compute average price and weight of cars, by origin{p_end}
{phang2}{cmd:sysuse auto, clear}{p_end}
{phang2}{cmd:sort foreign}{p_end}
{phang2}{cmd:collapsetofile (mean) price weight using carstats, by(foreign)}{p_end}
{phang2}{cmd:recover carstats, clear}{p_end}

{pstd}Compute average price and weight of cars that had a repair record of 3, by origin and mpg{p_end}
{phang2}{cmd:sysuse auto, clear}{p_end}
{phang2}{cmd:sort foreign mpg}{p_end}
{phang2}{cmd:collapsetofile (mean) price weight if rep78 == 3 using carstats, by(foreign mpg) replace}{p_end}
{phang2}{cmd:recover carstats, clear}{p_end}

{pstd}Include a macro and scalar in the file{p_end}
{phang2}{cmd:sysuse auto, clear}{p_end}
{phang2}{cmd:sort foreign mpg}{p_end}
{phang2}{cmd:global mymacro = "blue"}{p_end}
{phang2}{cmd:scalar myscalar = 3.1415}{p_end}
{phang2}{cmd:collapsetofile (mean) price weight if rep78 == 3 using carstats, by(foreign mpg) replace}{p_end}
{phang2}{cmd:clear all}{p_end}
{phang2}{cmd:macro drop _all}{p_end}
{phang2}{cmd:di "$mymacro"}{p_end}
{phang2}{cmd:cap di myscalar}{p_end}
{phang2}{cmd:recover carstats}{p_end}
{phang2}{cmd:di "$mymacro"}{p_end}
{phang2}{cmd:di myscalar}{p_end}



Create a new paste based on this one


Comments: