-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckinvariant.sthlp
64 lines (48 loc) · 2.73 KB
/
checkinvariant.sthlp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{smcl}
{* *! version 1.0.1 02feb2021}{...}
{findalias asfradohelp}{...}
{vieweralsosee "" "--"}{...}
{vieweralsosee "[R] help" "help help"}{...}
{viewerjumpto "Syntax" "checkinvariant##syntax"}{...}
{viewerjumpto "Description" "checkinvariant##description"}{...}
{viewerjumpto "Examples" "checkinvariant##examples"}{...}
{viewerjumpto "Author" "checkinvariant##author"}{...}
{viewerjumpto "Website" "checkinvariant##website"}{...}
{title:Title}
{phang}
{bf:checkinvariant} {hline 2} Check if a variable is invariant within a group
{marker syntax}{...}
{title:Syntax}
{p 8 15 2}
{opt checkinvariant} [{it:varlist} , by({it:varlist}) {it:options}]
{synoptset 20 tabbed}{...}
{synopthdr}
{synoptline}
{synopt:{opt allowmiss:ing}}Consider as invariant the case where a variable has missing values and a unique non-missing value within each group{p_end}
{synopt:{opt fill}}Replaces missing values with the unique non-missing value within each group. Requires {opt allowmiss:ing}{p_end}
{synopt:{opt dropinvar:iant}}Drops the invariant variables (including the filled ones when fill is called){p_end}
{synopt:{opt dropvar:iant}}Drops the variant variables{p_end}
{synopt:{opt keepinvar:iant}}Keeps the invariant variables (including the filled ones when filled is called) and the {it:by} variables{p_end}
{synopt:{opt keepvar:iant}}Keeps the variant variables and the {it:by} variables{p_end}
{synopt:{opt verb:ose}}Print results as each variable is checked{p_end}
{synoptline}
{p2colreset}{...}
{marker description}{...}
{title:Description}
{pstd}This command checks whether a given variable is constant or varies within the unique values of another group of variables. It is useful to ensure that panel datasets are coherent (e.g. attributes that should be constant within unit or time period indeed are).
{pstd}The command also returns scalars and macros with the number and lists of variant and invariant variables that can be used in subsequent commands.
{pstd}The only dependency of this command is gtools, by Mauricio Caceres, about which you can find at {browse "https://github.com/mcaceresb/stata-gtools"}.
{pstd}In the repository where the {cmd:checkinvariant} is maintained, you can find a file with tests for the command that should verify that it is working properly. This can be particularly useful if you intend to make extensions to the command.
{marker examples}{...}
{title:Examples}
sysuse auto, clear
gen brand = make
replace brand = regexr(brand, " .*", "")
checkinvariant, by(brand)
{marker author}{...}
{title:Author}
{pstd}Luís Fonseca, London Business School.
{pstd}Website: {browse "https://luispfonseca.com"}
{marker website}{...}
{title:Website}
{pstd}{cmd:checkinvariant} is maintained at {browse "https://github.com/luispfonseca/stata-misc"}{p_end}