I need to create a graph showing values over time by treatment group. Say I am looking at Hemoglobin as my variable. If I have a variable for each Hemoglobin at Baseline, Hemoglobin at 24hrs, Hemoglobin at 48 hrs, and Hemoglobin at 72hrs, and a variable for Treatment ID (Treatment A or Treatment B), is it possible to graph all of these values over time by Treatment ID in SAS?
Thanks!
@richaemi wrote:
I need to create a graph showing values over time by treatment group. Say I am looking at Hemoglobin as my variable. If I have a variable for each Hemoglobin at Baseline, Hemoglobin at 24hrs, Hemoglobin at 48 hrs, and Hemoglobin at 72hrs, and a variable for Treatment ID (Treatment A or Treatment B), is it possible to graph all of these values over time by Treatment ID in SAS?
Thanks!
Yes.
X axis value as the timepoint, Y axis variable as the measurement, Group by treatment. A number of different plot types may work.
data example; input time meas trt; datalines; 0 22 1 24 21 1 48 24 1 72 25 1 0 15 2 24 15 2 48 18 2 72 17 2 0 8 3 24 9 3 48 10 3 72 11 3 0 24 1 24 24 1 48 25 1 72 27 1 0 18 2 24 17 2 48 18 2 72 19 2 0 10 3 24 11 3 48 11 3 72 13 3 ; run; proc sgplot data=example; /* values*/ scatter x=time y=meas/group=trt; /* fit straight line through with confidence bands for the mean*/ reg x=time y=meas/group=trt clm; run;
If you want to connect points that would be a series plot but you need more information to avoid having the right end of the graph try to connect back to the left end.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.