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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.