Published on :

Regression Analysis and SASHELP Metadata Exploration

This code is also available in: Deutsch Español Français
Awaiting validation
The script is divided into four functional blocks. The first block performs regression analysis to understand the relationship between individuals' weight and height. The second block uses ODS to capture metadata of all objects (tables, views, etc.) in the `sashelp` library and stores them in a work dataset named `m`, while suppressing the default display of `PROC CONTENTS`. The third block prints the content of dataset `m`, filtered to show only 'DATA' type entries, allowing visualization of SAS© tables. The last block directly displays the `sashelp` library metadata to the console, without ODS redirection.
Data Analysis

Type : SASHELP


The data used for regression comes from the `class` dataset of the standard `sashelp` library. Metadata exploration is also performed on the `sashelp` library itself.

1 Code Block
PROC REG
Explanation :
This block executes the linear regression procedure (`PROC REG`). It specifies that the data comes from the `class` dataset of the `sashelp` library. The `model weight = height;` statement defines a model where `weight` is the dependent variable and `height` is the independent variable. `QUIT;` terminates the procedure.
Copied!
1 
2PROC REG
3DATA=sashelp.class;
4model weight = height;
5QUIT;
6 
2 Code Block
PROC CONTENTS Data
Explanation :
This block is designed to extract metadata from SAS objects. `ODS SELECT NONE;` temporarily suppresses all ODS output to the screen. `PROC CONTENTS DATA=SASHELP._ALL_;` analyzes all objects (`_ALL_`) in the `sashelp` library. `ODS OUTPUT MEMBERS=M;` redirects the `members` output table (containing metadata) to a new dataset named `m` in the temporary work library. `ODS SELECT ALL;` re-enables all ODS output.
Copied!
1ods select none;
2PROC CONTENTS DATA=sashelp._all_;
3 ods OUTPUT members=m;
4RUN;
5ods select all;
3 Code Block
PROC PRINT
Explanation :
This block uses `PROC PRINT` to display the content of the last created dataset, which is `m`. The `WHERE MEMTYPE = 'DATA';` clause filters observations to show only those where the member type is 'DATA', i.e., SAS tables.
Copied!
1PROC PRINT;
2 where memtype = 'DATA';
3RUN;
4 Code Block
PROC CONTENTS
Explanation :
This last block re-executes `PROC CONTENTS` on `sashelp._all_` to display the complete metadata of the `sashelp` library directly in the default ODS output, as ODS outputs were re-enabled previously.
Copied!
1PROC CONTENTS DATA=sashelp._all_;
2RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.