BookmarkSubscribeRSS Feed
GMartel
Fluorite | Level 6

Hi,

 

I am trying to create a line graph for pressure measurements made a various time points. Each time point variable contains pressure measurements for each subject (eg. t1, t2, t3, t4, etc.). These time point variables should each form my x-axis. The pressure measurements within each variable should me my y axis. I then have an intervention coded 1/0, for which I would like to dichotomize the data, creating two line graphs.

 

I am hoping to plot means with error bars (SD or SE).

 

I have tried to look through posts and synthax guides but I am not finding a way to plot the x-axis as being each of my t1, t2, t3, t4 etc variables.

 

I am using 9.4.

 

Please help!

 

Guillaume Martel

5 REPLIES 5
PaigeMiller
Diamond | Level 26

The best way to do this is to create a numeric variable (let's call it TIME) which has numbers 1 through 4, and then draw a plot of Y versus TIME.

 

For example: (untested code)

 

proc sgplot data=have;
    series x=time y=y/group=intervention;
run;
--
Paige Miller
Reeza
Super User

1. Summarize your data so that it's ready to graph - don't expect SAS procs to do the calculations for you - that's a lot harder to get for a line chart specifically. 

2. Use SGPLOT to create your graphics.

 

The graph gallery has many examples - see line chart.

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n121lznfa1jnlvn1q95t0r5sd2gq.htm&doc...

 

Do you want a graph with two lines, two graphs side by side for easier comparison (SGPANEL) or two entirely separate graph objects?

 


@GMartel wrote:

Hi,

 

I am trying to create a line graph for pressure measurements made a various time points. Each time point variable contains pressure measurements for each subject (eg. t1, t2, t3, t4, etc.). These time point variables should each form my x-axis. The pressure measurements within each variable should me my y axis. I then have an intervention coded 1/0, for which I would like to dichotomize the data, creating two line graphs.

 

I am hoping to plot means with error bars (SD or SE).

 

I have tried to look through posts and synthax guides but I am not finding a way to plot the x-axis as being each of my t1, t2, t3, t4 etc variables.

 

I am using 9.4.

 

Please help!

 

Guillaume Martel


 

GMartel
Fluorite | Level 6

Thank you! I will review the documentation.

 

I can output the means + standard deviations/standard errors for team time point variable. Would you say that that is the simplest way to proceed?

 

I am hoping to create one graph with two lines. The actual line is optional. This is an example of what I am hoping to generate.

 

image.png

PaigeMiller
Diamond | Level 26

The HIGHLOW command of PROC SGPLOT will certainly create such a plot. You would have to compute the uppper and lower confidence interval limits yourself before running PROC SGPLOT.

--
Paige Miller
GMartel
Fluorite | Level 6

Thank you I will give it a try!

 

GM

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 5 replies
  • 1606 views
  • 0 likes
  • 3 in conversation