- data class;
- set sashelp.class(keep=age height weight);
- run;
- %let dsin=class;
- %let var=age height weight;
- %let rc=%sysfunc(open(&dsin));
- %if &rc %then %do;
- %let nobs=%sysfunc(attrn(&rc,nobs));
- %let rc=%sysfunc(close(&rc));
- %end;
- %let varcount=%sysfunc(countw(&var));
- data myout(keep=_rst_:);
- set &dsin end=_eof_;
- array _tmp_[&varcount,&nobs]_temporary_;
- array _rst_[&nobs];
- array _var_ &var.;
- do over _var_;
- _tmp_[_i_,_n_]=_var_;
- end;
- if _eof_ then do;
- do _idx1_=1 to &varcount;
- do _idx2_=1 to &nobs;
- /* _rst_[_idx2_]=_tmp_[&varcount-_idx1_+1,_idx2_]; *逆时针90;*/
- _rst_[_idx2_]=_tmp_[_idx1_,&nobs-_idx2_+1]; *顺时针90;
- end;
- output;
- end;
- end;
- run;
注意:
1. proc transpose 的结果是中心对称的,不是旋转得到的;
2. 将上面程序的输出作为输入,再次运行程序,可以将数据集再次旋转90度,这样就可以得到旋转180度的数据集;