BookmarkSubscribeRSS Feed
ab97_cd
Calcite | Level 5

Hi,

 

How can I add second proc univariate to this:

proc univariate data=set_out;
by date;
weight w1;
VAR price;
run;

I want to obtain wieghted mean by group variable, using w2 as wieght.

3 REPLIES 3
PaigeMiller
Diamond | Level 26

@ab97_cd wrote:

Hi,

 

How can I add second proc univariate to this:

proc univariate data=set_out;
by date;
weight w1;
VAR price;
run;

I want to obtain wieghted mean by group variable, using w2 as wieght.


I'm sorry this just isn't clear to me. You can certainly add a second PROC UNIVARIATE to your code, so I'm not sure what your question really is.

 

If all you want is weighted means, use PROC SUMMARY and not PROC UNIVARIATE.

--
Paige Miller
ab97_cd
Calcite | Level 5
Hi,
Within first weighted mean grouping by date, I want to compute again weighted mean using "group" with by option.
Tom
Super User Tom
Super User

If you have a complex weighting (sampling) design then you probably will need to use PROCSURVEYMEANS instead of UNIVARIATE or MEANS.

https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_surveymeans_toc.htm&docsetVersion...

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 806 views
  • 0 likes
  • 3 in conversation