程序代写代做代考 MET MA 603: SAS Programming and Applications

MET MA 603: SAS Programming and Applications

MET MA 603:
SAS Programming and Applications

Proc Transpose

1

1

Transposing Datasets
SAS datasets are organized into variables (columns) and observations (rows). Sometimes we need to change the organization of our data. Transposing a dataset means to change observations in a row into observations in a column, or to convert variables into observation and observations into variables.

2

2

The Transpose Procedure
The Transpose Procedure transforms an input dataset.
In the BY statement, list any grouping variables that should remain variables in the transposed dataset. The dataset must be sorted according to the variables listed.
In the ID statement, list a variable whose observations will become the new variable names in the transposed dataset.
In the VAR statement, list the variables whose observations will be transposed. Note: unless listed in the VAR statement, character data types are not transposed.
Proc Transpose data=test_data out=test_data_transposed ;
by variables-list ;
var variables-list ;
id variable ;
run ;

3

3

Practice
Use the Height_and_Weight_Survey.sas7bdat dataset.
Use Proc Transpose to organize the data as shown below (not all observations are shown):

4

4

Readings

Textbook section 6.14

5

5

ABC
123
456
789

A147
B258
C369

/docProps/thumbnail.jpeg

Leave a Reply

Your email address will not be published. Required fields are marked *