BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
brittneykp
Obsidian | Level 7

I am a Base SAS user that has been learning Enterprise Guide (6.1) over the last couple months.  As I've been converting some of my Base SAS programs over to EG as a learning exercise, I've come across a problem - I get slightly different results with a weighted frequency depending on which program I use.  My data is a survey sample of 3,508 observations that includes a weight variable to extrapolate the information to approximately 535,000 cases.

In Base SAS, I'm running a simple Proc Freq table on a single variable and weighting it with the "WEIGHT" statement.  I get a total of 316,666 observations for the conditions set.

When I run a Summary Tables task on the SAME dataset, and assign the weight variable to the "Frequency Count" task role, I get a total of 315,461 observations for the same conditions.

Am I missing something in how to weight data properly in Enterprise Guide?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

Summary Tables is using PROC TABULATE behind the scenes.  You might see if there are nuances in how TABULATE and FREQ use WEIGHT, or treat MISSING differently.  For a better comparison, you might try the Table Analysis task instead -- it uses PROC FREQ for n-way frequency analysis.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

11 REPLIES 11
ballardw
Super User

Frequency count is likely assuming that the values are that, counts. Which would be integers. So likely the fractional part of your weights is getting discounted. As and exercise, examine the integer and fractional parts of your weight variable and sum them separately. See if you get values close to 315,461 and 1205.

ChrisHemedinger
Community Manager

Summary Tables is using PROC TABULATE behind the scenes.  You might see if there are nuances in how TABULATE and FREQ use WEIGHT, or treat MISSING differently.  For a better comparison, you might try the Table Analysis task instead -- it uses PROC FREQ for n-way frequency analysis.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
TomKari
Onyx | Level 15

I've hit this before. I can't remember the exact details, but in one of the SAS procedures using a particular option truncates the weight to an integer, while there is a different option to use the full value of the weight. Some experimentation should clear it up for you.

Tom

brittneykp
Obsidian | Level 7

Thanks for the help!  Looks like PROC TABULATE's "FREQ" statement does indeed truncate the weights; when I choose the One-Way Frequency task instead of Summary Tables task, I get the correct values.  I guess I'll just have to be very careful which task I use when creating frequencies for my sample data.

TomKari
Onyx | Level 15

You can use Summary Tables, just make sure you use the Relative Weight instead of the Frequency Count. There are a few things that Summary Tables does that can't be done easily any other way.

brittneykp
Obsidian | Level 7

I didn't find that assigning the weight to Relative Weight worked in Summary Tables - my output still only included the actual number of observations when I did that and not the weighted values.  My understanding is that Relative Weight only works when computing statistics on other variables, not on frequency counts.

TomKari
Onyx | Level 15

Sorry, I was only looking at this thread with half an eye, and didn't notice that the discussion was about frequency counts. To get a weighted frequency count out of Summary Tables, use the Relative Weight, and the statistic that you want is Sum of Weights instead of N. I just tested it, and it works fine. Let me know if you have any problems.

brittneykp
Obsidian | Level 7

I tried to do this myself and it won't let me use the SumWgt statistic - I get a crossed out symbol when I try to drop it on the table.  The other stats work fine, and I have my weight variable set to the Relative Weight role. What am I missing?

TomKari
Onyx | Level 15

Although you're conceptually only doing a frequency count, I think that EG wants you to apply the Sum of Weights on an analysis variable. Try putting any numeric variable into your table request (make sure there are no missing values), and try applying the sum of weights statistic on that.

One thing to be aware of with PROC FREQ is it will fail most quickly because of a large result set...PROC TABULATE is better, and PROC MEANS is basically impossible to break.

brittneykp
Obsidian | Level 7

Well, I won't be able to use Summary Tables then, because most of the variables I am evaluating are character variables. Thanks for the help!

TomKari
Onyx | Level 15

Just add a numeric variable named "DummyVar" with a value of 1 on every record to your table, and you're good to go!

Tom

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 11 replies
  • 2599 views
  • 7 likes
  • 4 in conversation