BookmarkSubscribeRSS Feed
Sean_OConnor
Fluorite | Level 6

Folks,

 

I have been computing mean and medians using the following statement.

proc summary data = Quantity_of_Properties_1 nway completetypes;
	;
	format class $class. year_filed year_filed. county_y $county_y.  child_filed $child_filed.;
	class class year_filed county_y  child_filed/mlf;
	var realprice1;
	output out = Table_0_fil (drop=_TYPE_ /*_freq_*/) 
	median= med_price mean=mean_price;
run;

However, I would like to compute the geometric mean, but I understand I can only do it through proc surveymeans. Is there anyway to get the same kind of output as above with proc surveymeans?

 

I've tried to the following but it does not work so any help would be great.

 

PROC SURVEYMEANS data=prices geomean;
	format class $class. year_filed year_filed. county_y $county_y.  child_filed $child_filed.;
	class class year_filed county_y  child_filed;
	var realprice1;
	ods output statistics=i;
run;

 

 

7 REPLIES 7
ChrisHemedinger
Community Manager

PROC UNIVARIATE also can also be used -- see this article.  And the TTEST procedure.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
Sean_OConnor
Fluorite | Level 6

Thanks for this. It doesn't look like proc univariate can handle multi level formats though or am I incorrect on this?

SteveDenham
Jade | Level 19

Try a two-step process.  First, log transform realprice1 in a DATA step (for illustration purposes, let's call it lnrealprice1).  Then feed it through PROC SURVEYMEANS just as you have the untransformed value.  Finally, using the output dataset, exponentiate the mean, SD, confidence bounds, etc.  Make sure that you include the sampling weights in the PROC SURVEYMEANS call, using either the WEIGHTS or REPWEIGHTS statement.

 

Thanks go to @PeterClemmensen and @ChrisHemedinger  for the referral to Rick Wicklin's ( @Rick_SAS ) blog.

 

SteveDenham

Sean_OConnor
Fluorite | Level 6

Hi Steve,

It appears that surveymeans can't handle multilevel formats either. For instance, proc summary /mlf option works, but this doesn't appear to be the case with the other functions.

 

Would I be correct in this assumption?

ballardw
Super User

@Sean_OConnor wrote:

Hi Steve,

It appears that surveymeans can't handle multilevel formats either. For instance, proc summary /mlf option works, but this doesn't appear to be the case with the other functions.

 

Would I be correct in this assumption?


You really should have defined in your initial question that the groups were defined by a multilabel format, if that is what you mean by "multilevel". Most formats are "multilevel" unless you are mapping all values to a single one. The documentation for Multilabel has the procedures that support the feature.

 

To use SURVEYMEANS you would make additional DOMAIN variables for each level and use a DOMAIN statement such as:

 

domain Level1  Level1*Level2; to get the combined mean of Level1 and Level2 plus an overall for each Level1 value.

 

 

mkeintz
PROC Star

You could also make a temporary dataset with a new variable equal to the log10(realprice1) or log(realprice1), followed by proc summary with the class statements you want, and adding the new variable to the var statement.

 

Then take the output dataset  TABLE_0_FIL  produced by the proc summary, and get the antilog (either 10**x or exp(x)) of the mean of the new variable.  You will have the desired subgroup geometric means alongisde the other stats you requested.

 

 

 

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 7 replies
  • 768 views
  • 5 likes
  • 6 in conversation