I realized that in my data set the age variables are in the range [-88, +137], so I want to get rid of those unreasable ages.
I can subset the data set using if condition. But I wonder if there is a way that I can calculate the means, say, in (0,100) range, in the proc means procedure?
And is there a way to count how many cases with age <0 or age >100?
Thank you.
And for the extremes
proc freq data= yourdata;
where age < 0 or age>100;
tables age;
run;
Thank you very much.
I used where age >0 and age <100; and it worked.
but when I use where age in (0:100) I had many cases not included. not sure why.
Please note that the notation (0:100) stands for the set of integers {0, 1, 2, ..., 99, 100}. So, for example age=12.3 does not satisfy the condition age in (0:100), although it satisfies 0<age<100.
Are you sure that all your age values are integers? You could check this with the following step:
proc freq data=yourdata;
where age ne intz(age);
tables age;
run;
If the output of the above PROC FREQ contains any integer value of AGE, then you've encountered a numeric representation issue and you may want to round your AGE values, e.g. like age=round(age, 1e-9).
Example:
data ttt;
age=9.9/3.3; /* should equal 3, mathematically */
run;
proc freq data=ttt;
where age ne intz(age);
tables age; /* looks like 3, but is not 3! */
run;
And for the extremes
proc freq data= yourdata;
where age < 0 or age>100;
tables age;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.