Hi everyone,
I am trying to solve the following question but I am lost as to how to do this. There are two datasets involved but they can be linked by patient id which is present in both datasets. However I am trying to calculate statistics of three variables as described in my code below: Any thoughts or queries. Sorry, I can't post the dataset but I'd appreciate some help.
/*8
Using the SAS datasets demogdemo and visitdemo and PROC MEANS with the CLASS statement,
compute the mean, median, 25th percentile, 75th percentile, and the number of non-missing
values for the variables CD4, Weight, and Age for each value of civil status
including missing. Report the statistics to three decimal places. In the same PROC MEANS,
create a summary dataset with the OUTPUT statement containing the median and mean of CD4,
Weight, and Age. Using _TYPE_, print only the overall (i.e. all civil
status categories combined) mean and median from this summary dataset.
*/
title "Using a CLASS Statement with PROC MEANS";
proc means data=lb.visitdemo n mean median Q1 Q3 maxdec=3; *what about demogdemo?;
class civilstatus;
var CD4 Weight Age ;
run;
T
proc means accepts one dataset as input, so you will have to do the join first.
proc means accepts one dataset as input, so you will have to do the join first.
How would you join these datasets?
@Flexluthorella wrote:
How would you join these datasets?
With SQL or with a data step merge.
Does it matter if you use proc sql or merge if you want to use the proc means by class statement?
No. You only need to put all necessary data into one dataset to feed into proc means. How you created that dataset is of no interest to the procedure.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.