turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Using different weights in Proc Means

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-25-2013 04:43 PM

This is a part in my macro:

PROC MEANS DATA=&DSN NOPRINT NWAY;

CLASS TIME_PERIOD QNUM aggregate BRAND;

VAR FLAG;

WEIGHT XMKT_WEIGHT;

OUTPUT OUT=&DSN._WTDMEANS SUMWGT=BASE_WTD SUM=CNT_WTD MEAN=PER_WTD ;

RUN;

For example, I have Markets=1,2,3,4,......60 and for example. aggregate=1002 combines markets (5,6, 13,14).

So in the above proc means, I want WEIGHT = WEIGHT (my weight variable ) if aggregate=1,2,....60 but I want it to use XMKT_WEIGHT if it's a combination of markets viz aggregate=1002. How can I tell proc means which weight to use based on a condition.

If it helps, aggregate=1 is market=1, aggregate=2 is market=2......upto aggregate=60 is market=60...and then aggregate=1000 is market=1,2,3, aggregate=1001 is market=2, 3, 9, 10 etc which I have in a table:

AGGREGATE MARKET

1 1

2 2

1002 5

1002 6

1002 13 .......... ETC

Thanks!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-25-2013 04:45 PM

Create a new weight variable in a data step instead that has the weights it would need to use. I don't believe there's a way to implement that in proc means, besides running different procs.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

01-25-2013 07:09 PM

Transpose your data or otherwise rearange it such that you have a BY variable that represents the change in weight variables.