BookmarkSubscribeRSS Feed
joebacon
Pyrite | Level 9

I am looking to make a spaghetti plot for many observations with several stipulations. I want to compare two graphs. I want to  separately consider those who have an age 18 BMI of 20-25 (“normal weight”) and those whose age 18 BMI is 25-50 (overweight). I was planning on making two graphs because I do not know how to superimpose my data or make more than one group (would love input on this if anyone knows). However, I have this code below and it's close but not quite there.

 

proc sgplot data = obese;
where ID LE 30 and age GE 18;
where also 25 >=BMI >= 20; /*I want this to be when when age is 18 but as age increases it then it can surpass these limits.*/
	series x = Age y = BMI / group= ID break curvelabel;
	yaxis values= (20 to 30 by 2);
	xaxis values= (18 to 35 by 1 );
	run;

I have the same code for the other graph. I have tried using the following but then it restricts it from the the people who really increase in BMI (which im interested in).

 

 

	proc sgplot data = obese;
where ID LE 40 and age GE 18;
where also 60 >=BMI >= 25 and Age = 18;
	series x = Age y = BMI / group= ID break curvelabel;
	yaxis values= (20 to 30 by 2);
	xaxis values= (18 to 35 by 1 );
	run;

Any ideas? I am open to any suggestions at all. Even if they are "Why dont you use a different graph" etc. I'm new to SAS and VERY new to sgplot.

 

Thanks in advance.

 

1 REPLY 1
PaigeMiller
Diamond | Level 26

You could also modify the data set so that there is an indicator variable which shows if the person is normal weight or overweight, and the in PROC SGPLOT use the BY statement to get your two distinct plots.

 

You could also use a single WHERE statement rather than two separate where statements, but then you have to call PROC SGPLOT twice. But really, this isn't a job for the WHERE statement in PROC SGPLOT.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 2995 views
  • 0 likes
  • 2 in conversation