Download presentation
Presentation is loading. Please wait.
Published byBrianne Hart Modified over 8 years ago
1
San Francisco 2013
2
Theme: Strength in Numbers Big Data and Business Intelligence (BI) Applications
3
Paper 428-2013: Cox Propotional Hazard Model Evaluation in one Shot. (Polina Kukhareva. Proceedings of the SAS® Global Forum 2013 Conference. Cary, NC: SAS Institute Inc. ) Martingale residual plots Tests linearity in the log scale assumption Schoenfeld residual plot to check PH
4
%let predictors=age systolic_bp diastolic_bp ldl bmi diabetes smoking sex treatment activity; %let class = diabetes(ref="0") smoking(ref="0") sex(ref="0") treatment(ref="0") activity(ref="average") %check_Cox_assumptions_all (_NUMBER=1, _DATA=simCox, _PREDICTORS=&predictors, _class=&class, _OUTCOME=CV_event, _FU=CV_time, _STOP= activity, _EXCLUDE= systolic_bp diastolic_bp ldl diabetes smoking sex)
5
Quantlife Procedure for Survival Analysis ◦ Covariate analysis ◦ Summarize lifetime distribution by percentiles (25 th, 50 th, 75 th ) ◦ Separate regression models for each quartile proc quantlife data=pbc log method=na plot=(quantplot survival) seed=1268; model Time*Status(0)=logBilirubin logProtime logAlbumin Age Edema / quantile=(0.1 0.2 0.3 0.4 0.5 0.6 0.75); run;
6
IDDateTimeGender Score health Score mobility 122-Sep-091M1832 109-Oct-092M2229 203-Mar-101F720 214-Mar-102F1625 320-Apr-101F822 329-Apr-102F17 403-May-101F1119 429-May-102F2025
7
proc transpose data=have out=want (drop=_:) prefix=var1_; by idnum; var var1; id date; run;
8
What would Art do?
9
Paper 538-2013 SAS Global Forum 2013. Beyond the Basics. Arthur S. Tabachneck, Ph.D., myQNA, Inc., Thornhill, Ontario Canada Xia Ke Shan, Chinese Financial Electrical Company, Beijing, China Robert Virgile, Robert Virgile Associates, Inc., Lexington, MA Joe Whitehurst, High Impact Technologies, Atlanta GA
10
SAS Marco Flips tall data sets to wide data sets or flips wide data sets to wider data sets Macro creates and runs a program that creates a data step using arrays
11
%macro transpose(libname_in=mydata, libname_out=, data=, out=, by=, prefix=, var=, autovars=, id=, var_first=, format=, delimiter=, copy=, drop=, sort=, sort_options, guessingrows=);
12
How the macro works if we have: dataset have idnumdatevar1var2 131MAR20131SD 130JUN20132EF 130SEP20133HK 131DEC20134HL 231MAR20135GH 230JUN20136MM 230SEP20137JH 231DEC20138MS Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013.
13
How the macro works and we need: dataset need idnumvar1 Qtr1 var2 Qtr1 var1 Qtr2 var2 Qtr2 var1 Qtr3 var2 Qtr3 var1 Qtr4 var2 Qtr4 11SD2EF3HK4HL 25GH6MM7JH8MS and we submit: %transpose(data=have, out=want, by=idnum, id=date, format=qtr1., delimiter=_Qtr, var=var1-var2, sort=yes) Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013.
14
How is it Different/Better than Proc Transpose? Does it Go Beyond Proc Transpose?
15
and you can use almost all the features that you can with PROC TRANSPOSE plus some additional ones %transpose(libname_in=,libname_out=, data=,out=, by=,prefix=, var=,autovars=, id=,var_first=, format=,delimiter=, copy=,drop=, sort=,sort_options=, use_varname=,preloadfmt=, guessingrows=) Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013
16
parameter: drop the variable(s) you want dropped from the transposed file ** only relevant if you want to drop any of the by variables ** the %transpose macro's features %transpose(libname_in=,libname_out=, data=,out=, by=,prefix=, var=,autovars=, id=,var_first=, format=,delimiter=, copy=,drop=, sort=,sort_options=, use_varname=,preloadfmt=, guessingrows=) Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013
17
%transpose(libname_in=,libname_out=, data=,out=, by=,prefix=, var=,autovars=, id=,var_first=, format=,delimiter=, copy=,drop=, sort=,sort_options=, use_varname=,preloadfmt=, guessingrows=) parameter: autovars determines whether char(acter), num(eric) or all variables should be transposed if the var parameter is null * * * * * * F E A T U R E * * * * * * Where PROC TRANSPOSE will only include all numeric variables if there is no var statement, this parameter lets you indicate if you want all numeric variables, all character variables or simply all variables the %transpose macro's features Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013
18
parameter: sort the %transpose macro's features %transpose(libname_in=,libname_out=, data=,out=, by=,prefix=, var=,autovars=, id=,var_first=, format=,delimiter=, copy=,drop=, sort=,sort_options=, use_varname=,preloadfmt=, guessingrows=) whether the input dataset should be sorted (YES or NO): for both, only &by, &id, &var and © variables will be used If Yes, the input data will be sorted using the noequals option Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013
19
What’s in it for me??
20
%transpose(data=have, out=want, by=idnum, var=var1, id=date, sort=yes, delimiter=_) Would you be interested in knowing how to obtain the same result with the following code? No system variables to drop No need for a prefix (var names automatically included) No need to differentiate between options and statements as they are all of the form: parameter=value, No need to presort your data Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013
21
%transpose(data=have, out=need, by=idnum, id=date, format=qtr1., delimiter=_Qtr, var=var1-var2, sort=yes) would you be interested in knowing how to obtain the right result with the following code? only requires one step only needs one pass through the data doesn't produce distorted results can run more than 50 times faster than PROC TRANSPOSE How about if you knew that the macro: Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013
22
Compare the performance of the following two sets of almost identical code run on a file with 40,000 records and 1,002 variables PROC SORT data=have out=need; by idnum date; run; took 2.41 seconds CPU time PROC TRANSPOSE data=need out=want (drop=_:) prefix=var1_Qtr; by idnum; var var1; id date; format date Qtr1.; run; took 0.74 seconds CPU time Art Tabachneck. A Better Way to Flip(Transpose) a SAS® Dataset. Presented at MWSUG 24, 2013
23
Thanks to Art Tabachneck for providing access and sharing his slides http://www.sascommunity.org/wiki/A_Better_ Way_to_Flip_(Transpose)_a_SAS_Dataset
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.