Syntax, PROC TRANSPOSE
statement:
PROC TRANSPOSE<DATA=input-data-set> <OUT=output-data-set> <PREFIX=prefix>;
BY <DESCENDING> variable-1
<NOTSORTED>; ID variable(s);
VAR variable(s);
Note: When you use PREFIX= with
an ID statement, the variable name begins with the prefix value followed
by the ID value.
Tip:You can use name literals
(n-literals) for the value of PREFIX. Name literals are helpful when
specifying typographical or foreign characters, especially when VALIDVARNAME=ANY.
To recall how
VALIDVARNAME=ANY interacts with name literals, see VALIDVARNAME=System Option.
|
proc transpose data=cert.class out=score_transposed; /*#1*/ run; proc print data=score_transposed noobs; /*#2*/ title 'Scores for the Year'; run;
1 | PROC TRANSPOSE transposes only the numeric variables Score1, Score2, Score3, and Homework. OUT= puts the result of the transposition in the data set Score_Transposed. |
2 | PROC PRINT prints the Score_Transposed data set. The NOOBS option suppresses the printing of observation numbers. |
Syntax, VAR statement:
VAR variable(s);
|
proc transpose data=cert.trials out=transtrials1; /*#1*/ var Cholesterol Triglyc Uric; /*#2*/ run; proc print data=transtrials1; /*#3*/ run;
1 | Transpose the data set Cert.Trials and put the results of the transposition in the Transtrials1 data set. |
2 | The VAR statement specifies the Cholesterol, Triglyc, and Uric variables as the only variables to be transposed. |
3 | Use the PROC PRINT statement to print the Transtrials1 data set. |
Syntax, ID statement:
ID variable(s);
|
proc transpose data=cert.trials out=transtrials2; /*#1*/ var cholesterol triglyc uric; /*#2*/ id name testdate; /*#3*/ run; proc print data=transtrials2; /*#4*/ run;
1 | Transpose the data set Cert.Trials and put the results of the transposition in the Transtrials2 data set. |
2 | The VAR statement specifies the Cholesterol, Triglyc, and Uric variables as the only variables to be transposed. |
3 | The ID statement specifies Name and TestDate as the variables whose nonmissing formatted values name the transposed variables in the output data set, Transtrials2. Because the ID statement specifies two variables, the values of those variables are concatenated to create the new variable names. |
4 | Use the PROC PRINT statement to print the Transtrials2 data set. |
Syntax, BY statement:
BY <DESCENDING> variable-1
<NOTSORTED>;
|
proc transpose data=cert.trials out=transtrials3; /*#1*/ var cholesterol triglyc uric; /*#2*/ id name; /*#3*/ by testdate; /*#4*/ run; proc print data=transtrials3; /*#5*/ run;
1 | Transpose the data set. The OUT= option puts the results of the transposition in the Transtrials3 data set. |
2 | The VAR statement specifies the Cholesterol, Triglyc, and Uric variables as the only variables to be transposed. |
3 | The ID statement specifies Name as the variable whose nonmissing formatted values name the transposed variables in the output data set, Transtrials3. |
4 | The BY statement creates BY groups for each unique TestDate. The procedure does not transpose the BY variables. |
5 | Use the PROC PRINT statement to print the Transtrials3 data set. |