BookmarkSubscribeRSS Feed
richaemi
Fluorite | Level 6

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!

1 REPLY 1
ballardw
Super User

@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.

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1222 views
  • 0 likes
  • 2 in conversation