Stata has no concept of "columns" except in a matrix.
Why don't you use the terminology of "variables"?
What Stata allows is specification of a datatype.
That is evidently not as restrictive as you want.
A long time ago, Stata had an interactive
command -modify-, and interactive commands could be written
that used constraints to filter input. But
they could always be subverted by direct
use of -replace-, -edit-, etc.
Otherwise, the main possibility is checking
existing data with -assert-.
You can go
. assert inrange(var1,0,30) & var1 == int(var1)
and Stata will squawk if this is not true.
Note that you need another word, even privately,
for what you call format, as Stata's concept is
quite different.
As for -protect-, this doesn't ring any bells
in Stata terms. I can't see any case for Stata
usurping the functions of an operating system
and/or network.
On the whole, what you want is more in the
line of database software than statistical
software.
Nick
[email protected]
Rafal Raciborski
> is there a way to impose certain restrictions on individual
> columns in
> a Stata dataset? e.g., numeric values must be in the range
> [0,30] and
> integers or, for a SSN column, character values must be of the format
> XXX-XX-XXXX and, at the same time, must be of length 11. if they are
> not, the user will be warned and the change/input rejected.
>
> furthermore, is there a way to password-protect an individual
> column/whole dataset so that only authorized users can
> copy/modify it?
> a milder protection could be that one can make an unprotected copy of
> the protected column/dataset and modify the copy; a stricter
> protection
> would not even allow making changes in copies (or even copying in the
> first place).
>
> i was thinking about something like:
>
> -----------------
> attribute command
> -----------------
>
> attr var1, range(0,30) & integer
> attr var2, range(>1)
>
> attr var3, format(nnn-nn-nnnn) & length(11)
> attr var4, format(CC) // meaning two capitalized characters
>
> attr dir
> attr list var1
> attr drop var1
> attr drop _all
>
>
> ------------------
> protection command
> ------------------
>
> protect var1 "password", mild // default is strict
> protect data "password"
>
> protect // a general query whether password-protection exists
> protect drop var1 "password" // eliminates protection
> protect drop data "password"
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/