BookmarkSubscribeRSS Feed
Wolverine
Quartz | Level 8

As I detailed in this post I'm trying to make a "Table 1" summary table and another additional table of descriptive statistics for dozens of variables. Generating the proper results is relatively easy. But rearranging those results for dozens of variables and putting them into a well-organized summary table takes a lot of code. The TableN macro does this extremely well, but it doesn't have a provision to add weights.

 

Before I go any further, has anyone else ever run into this issue? I'm hoping there may be a modified version of the macro that can include weights.

 

First and foremost, I need to add the person weight variable PUFFWGT. I believe all of the procs used in the macro (such as PROC MEANS, PROC FREQ, PROC UNIVARIATE, etc.) can include a WEIGHT statement for the person weight.

 

For simplicity sake, I'm attempting to hardcode PUFFWGT into these procedures. However, I'm discovering that the macro takes the input dataset, extracts key variables, and divides them into multiple files that each have a standard format that is specific to the macro. The datasets to which the Procs are actually applied no longer have the weight variables or any of the original variable names. The varnames and labels are presumably added back in at the end. So I can't just add the weight statement, because the weight variable is no longer there.

1 REPLY 1
ballardw
Super User

If your data is from a complex sample, sort of implied with "replicate weights" then Procs Means, Univariate and Freq should not be used as they will not apply the weight according to the sample design.

 

My personal macros come in two basic flavors: calculate the numbers and display the numbers. That way any data set with the numbers can be displayed. The TableN macro combines those two pieces and from the little I looked at the code I am not going to attempt to "fix" something that the author spent years writing. Especially where you should be using the Procs Surveymeans or Surveyfreq which use quite different output data sets, having to use ODS OUTPUT and resultant sets are much more complex.

 

IF the TableN macro can be convinced not to attempt to create confidence intervals but use variables from a data set directly then you would be better off summarizing the data with Surveyfreq/Means, restructuring the data set and sending that to the macro.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

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
  • 1 reply
  • 255 views
  • 0 likes
  • 2 in conversation