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

Hello, 

I am applying weight statement at proc summary below.

However, it did not bring the weighted count. 

I am wondering how this can work.   Thanks. 

(Just use proc summary , no proc freq). 

 

proc summary data=a1 chartype completetypes;
class treatment;
types treatment;
weight IPW; /*weight dose not work?*/
output out=ae_1;
quit;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
The following is much clear to understand the weighted count by proc summary.

proc summary data=a1 chartype completetypes;
class treatment;
types treatment;
var ipw;
output out=ae_1 sum=sum_weights;
quit;

View solution in original post

5 REPLIES 5
ballardw
Super User

If your IPW variable is a count then you likely mean to use FREQ not Weight statement.

 

proc summary data=a1 chartype completetypes;
class treatment;
types treatment;
Freq IPW; 
output out=ae_1;
quit;

 

Freq uses the variable as a count of records where all the variables are the same.(or at least the one you are using for other statements in the procedure).

Weight will not change the sample size the way Freq does.

 

Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
Thanks for the response.
Yes. Proc Freq is the normal way for the count.
I am using PROC SUMMARY, due to try not to change the reference program I got from others , but I need to add weight for the patients.
PaigeMiller
Diamond | Level 26

However, it did not bring the weighted count. 

 

You can compute the sumwgt statistic.

 

proc summary data=a1 chartype;
class treatment;
weight IPW; 
output out=ae_1 sumwgt=sum_weights /* Other statistics required go here */;
quit;
--
Paige Miller
Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
Thanks Paige for the suggestion.
I customized your code , "adding var statement" as below, then it works!
proc summary data=a1 chartype completetypes;
class treatment;
types treatment;
var ipw;
weight IPW; 
output out=ae_1 sumwgt=sum_weights;
quit;
Ivy
Quartz | Level 8 Ivy
Quartz | Level 8
The following is much clear to understand the weighted count by proc summary.

proc summary data=a1 chartype completetypes;
class treatment;
types treatment;
var ipw;
output out=ae_1 sum=sum_weights;
quit;

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!

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
  • 5 replies
  • 2520 views
  • 0 likes
  • 3 in conversation