Hi there, I am an M.Sc student with a question about coding for proc univariate.
I am wondering when it is appropriate to use a by statement when writing the code for Proc Univariate?
Here are my codes, and I am wondering which is the correct one
proc sort data=____;
by trt dur;
proc univariate data=____ normal plot;
var ____;
by trt dur;
run;
OR would this be the right code
proc univariate data=____ normal plot;
var ____
run;
trt=treatment
dur= duration
I have 5 treatments, with 2 time durations per treatment
If you want to get statistics from PROC UNIVARIATE for each combination of TRT and DUR, then the first code is correct.
If you want to get statistics from PROC UNIVARIATE over the entire data set, then the second code is correct.
Or separate analysis only by trt or only by dur then only one variable on the BY statement.
Note that each option other than the overall analysis would require different sorts of the data prior to the Proc Univariate as data sort BY order must match the BY statement.
@ballardw wrote:
Or separate analysis only by trt or only by dur then only one variable on the BY statement.
Note that each option other than the overall analysis would require different sorts of the data prior to the Proc Univariate as data sort BY order must match the BY statement.
Depending on what statistics are needed from this analysis, PROC SUMMARY can do this without different sorts of the data.
@PaigeMiller wrote:
@ballardw wrote:
Or separate analysis only by trt or only by dur then only one variable on the BY statement.
Note that each option other than the overall analysis would require different sorts of the data prior to the Proc Univariate as data sort BY order must match the BY statement.
Depending on what statistics are needed from this analysis, PROC SUMMARY can do this without different sorts of the data.
Absolutely. With the example code showing requests for plots and not knowing if @sjl347 might be looking for the other by group outputs I thought it might be helpful to remind a new user about the sort requirement for different by groups.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: