Hi,
I have the following simple proc means with class.
There are a few classes that should produce a variety of results, however, this code takes only the max class and populates it everywhere. What would cause this to happen?
proc means data=tabs_dist_stats mean max n;
class SORT_ORDER;
var TabsEff_NOTABS TabsEff_TABS;
run;
An excerpt of the output is attached.
Can you show us a representative sample of your data?
I can't see your .pdf file in my browser.
The input data is below.
One possibility: Does the variable SORT_ORDER have a format permanently associated with it? PROC CONTENTS will reveal that.
If that's, the case, the format can group actual values into formatted levels. You can temporarily remove the format by adding this statement to the PROC MEANS:
format SORT_ORDER;
@capam wrote:
Hi,
I have the following simple proc means with class.
There are a few classes that should produce a variety of results, however, this code takes only the max class and populates it everywhere. What would cause this to happen?
Please describe what "takes only the max class and populates it everywhere" means. Your output example has sort_order, your class variable, with multiple values and so "only the max class" doesn't make sense at all to me.
If you run this code I think you will find that you do not have unique values for the variable TabsEff-NOTABS.
proc freq data=tabs_dist_stats; tables sort_order * tabsEff_NoTabs/ list; run;
That will produce a table of each value of sort_order pared with each value of tabsEff_NOTABS as they exist in your data with one row per combination and a count.
When I see repeated values for the mean of an analysis variable within a class variable as you show it usually means that the exact same pattern (number and values) for the analysis variables are repeated for the class the variable. Not that in you result table the N values repeat for those group with the name number of values for the analysis variables for class 1113 through 1118: 7 non-missing values for TabsEff_NOTABS and 322 for TabsEff_TABS. Which exact same values show up again for N for the class variable values of 1130 through 1136. So you have lots of duplicated data in your data set.
@capam wrote:
Yes. I've somehow corrupted the data. Thanks.
Without seeing code a common issue like this can come from a data step that looks like:
Data want;
set want;
<stuff>.
run;
or especially
Data want;
set (or merge) want
dataset2
;
run;
If you add records or a number of other things you can replace your original data set with one containing more (or fewer!) records. And if you rerun the code testing to add additional variables you can do this multiple times.
So see if your previous code has any of the input/output sets with the same name.
And be very careful when using that construct.
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.