I have a data set of 200 observations, involving demographic variables (gender, age, income level etc) that I'm to test against some health related variables (blood pressure, cholesterol, glucose levels etc). I was thinking it'd be easier to manage if I was to use a class variable involving age, but in the file the data is to be read from, it gives all individual ages.
What I've attempted is some if else statements to sort of "create" a coding for age. I ran proc glm a few times, to compare against each health variable. The issue I'm having is that it seems to always assign agegroup to 1 when using it in a class statement, as can be seen in the code. It seems to me that it isn't running the if else construct for each observation.
My code can be found here. http://snipt.org/ugOi9
If you run it, and look in the class levels for each proc glm in the output, you can see that there's supposedly only one level for agegroup, and all are 1 which is where my issue is.
How can I fix my if else statements to properly assign agegroup to whichever the particular observation may fall in? If there's a more proper way to do this, what would that be?
Any input is greatly appreciated, thank you.
It is because of the order of statements in your datastep. Move the IF-ELSE statements after the input statement. You must read the data before you access its value. At the beginning of each datastep iteration, all variables, except those named in retain statements, take a missing value. And missing compares as inferior to any non missing number.
PG
It is because of the order of statements in your datastep. Move the IF-ELSE statements after the input statement. You must read the data before you access its value. At the beginning of each datastep iteration, all variables, except those named in retain statements, take a missing value. And missing compares as inferior to any non missing number.
PG
Wow, what a silly mistake for me to make. That makes perfect sense. Can't really modify an observation that doesn't exist yet.
Thank you very much.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.