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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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