weighted_stats
Compute weighted statistics (mean, median, percentiles, min, max, std) for a numeric survey variable, with optional filtering and grouping by another variable.
Instructions
Compute weighted descriptive statistics for a variable.
Args: variable: The numeric variable to analyze (e.g., 'ingc_pc', 'educ'). filter: Optional filter expression (e.g., "sexo == 1"). by: Optional grouping variable (e.g., "region", "sexo", "cohorte"). dataset: Which dataset to use (default: entrevistado).
Returns weighted mean, median, std, percentiles (25th, 75th), min, max, and sample sizes. If 'by' is specified, returns stats per group.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| variable | Yes | ||
| filter | No | ||
| by | No | ||
| dataset | No | entrevistado |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |