SAS : how to set combined group code and concatenated group name

This post shows a SAS code to set 1) combined group number and code and 2) concatenated group name for group-by estimations.


SAS : combined group code and concatenated name



We also use the sashelp.baseball dataset as a sample data which was used in the previous post below.



We assume that work.base2 dataset is prepared, which is already created in the previous post.



Grouping based on all enumerations of key columns


The following SAS code makes a set of group number (grno), code (grcd), and name (grnm) based on all enumerations of key columns such as League, Division, and Team.

SAS : how to set combined group code and concatenated group name

The above code produces the combined group information(no, code, name) which we intend to make.

SAS : how to set combined group code and concatenated group name


Grouping based on specific conditions of key columns


The following SAS code generates a set of group number (grno), code (grcd), and name (grnm) based on some user-defined conditions of key columns such as League, Division, and Team.
SAS : how to set combined group code and concatenated group name

We can find that the above code delivers the following grouped information which is filtered by some conditions.
SAS : how to set combined group code and concatenated group name


Difference between two groupings


To find the differences between two grouping methods, let's calculate group-by averages.
SAS : how to set combined group code and concatenated group name

As expected, averages of log salary are calculated by each groups as follows.
SAS : how to set combined group code and concatenated group name

These grouping methods are mainly used for repeated regressions by group such as pool-level regressions.

Period.

No comments:

Post a Comment

Tentative Topics (Keeping Track to Avoid Forgetting)

Segmented Nelson-Siegel model
Shifting Endpoints Nelson-Siegel model
Nadaraya-Watson estimator
Locally weighted scatterplot smoothing (LOWESS)
Time-Varying Parameter Vector Autoregressions (TVP-VAR)
Time-varying or Dynamic Copula
Bayesian VAR
Adrian-Crump-Moench (ACM) term premium model
GARCH-EVT-Copula approach