BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
matus2711
Fluorite | Level 6
poolcountaverageupperlower
120680.09530.10590.0846
261200.24080.24980.2319
362150.33900.34890.3291
446250.42440.43640.4125
516950.52680.54680.5069

Hello everyone, know someone how to easily get multiple lines plot from these data?
Upper and lower are confidence interval, average is mean. Count is not relevant and pool is some group.

I'll be glad for any help.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

UNTESTED CODE

 

proc sgplot data=have;
    series x=pool y=average;
    series x=pool y=upper;
    series x=pool y=lower;
run;

If you want tested code (and this is always a good idea anyway, @matus2711 ) provide the data as SAS data step code (instructions) and not as a screen capture, something you should just do automatically, every time you ask a question; and from now on we will expect data in this form and not as screen captures.

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

UNTESTED CODE

 

proc sgplot data=have;
    series x=pool y=average;
    series x=pool y=upper;
    series x=pool y=lower;
run;

If you want tested code (and this is always a good idea anyway, @matus2711 ) provide the data as SAS data step code (instructions) and not as a screen capture, something you should just do automatically, every time you ask a question; and from now on we will expect data in this form and not as screen captures.

--
Paige Miller
Rick_SAS
SAS Super FREQ

Usually, when someone wants a line plot there is an X (indep) and a Y variable (response). What variable do you want to use as X?

 

For these data, you can create a set of lines that show the average and CI for each group. This kind of plot is sometimes called a "forest plot."  It can be used to compare means of groups or to show odds ratios.

 

data Have;
input pool	count	average	upper	lower;
datalines;
1	2068	0.0953	0.1059	0.0846
2	6120	0.2408	0.2498	0.2319
3	6215	0.3390	0.3489	0.3291
4	4625	0.4244	0.4364	0.4125
5	1695	0.5268	0.5468	0.5069
;

proc sgplot data=Have;
   scatter x=pool y=average / yerrorlower=lower yerrorupper=upper;
run;

If you want a different plot, please specify or draw it on paper and upload a picture.

PaigeMiller
Diamond | Level 26

@matus2711 

Since the answer from @Rick_SAS is a better answer than mine, would you please mark his answer as correct? Thanks!

--
Paige Miller
Rick_SAS
SAS Super FREQ

To expand on Paige's gracious response, some graphical experts discourage connecting groups with line segments. There is no "Group=1.5" or "Group=2.8", so some folks argue that it is misleading to plot line segments. 

PaigeMiller
Diamond | Level 26

@Rick_SAS wrote:

To expand on Paige's gracious response, some graphical experts discourage connecting groups with line segments. There is no "Group=1.5" or "Group=2.8", so some folks argue that it is misleading to plot line segments. 


A good point from @Rick_SAS , it is a very common thing for people to treat groups as continuous in their plots, and (ideally) is should be a much less common situation.

--
Paige Miller
Ksharp
Super User
proc sgplot data=have;
    band x=pool upper=upper lower=lower/transpancy=0.5;
	series x=pool y=average;
run;

Ksharp_0-1628255177844.png

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 2513 views
  • 8 likes
  • 4 in conversation