BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sasprog
Calcite | Level 5

Hi community,

 

I’m learning MSM model and find a helpful paper published by SAS: https://support.sas.com/content/dam/SAS/support/en/books/analysis-of-observational-health-care-data-...


I was not able to follow the piece of code below on page 16:

 

DATA WEIGHTS;

merge weights predtrt predcen;

By patsc vis;

VWT=Predtrt*predcen;

If first.patsc then stabwt=VWT;

                   Else stabwt=VWT*DUM;

Retain DUM;

DROP DUM;

DUM=STABWT;

run;


how was DUM defined here? 

 

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

The variable DUM has the same the value as STABWT when the RUN statement is encountered.  But the DROP statement keeps it out of the WEIGHTS dataset.

 

However, DUM is retained, meaning each observation starts out with the value in DUM generated in the preceding observation.

 

So when the "else stabwt=vwt*dum;" statement is executed, it is actually calculating stabwt as the product of VWT from the current observation and STABWT from the prior observation.  EXCEPT when the current obs is the beginning of a new patsc group, when the "stabwt=VWT;" statement is executed.

 

In other words, STABWT=VWT*lag(STABWT) except when starting a new patsc.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

2 REPLIES 2
mkeintz
PROC Star

The variable DUM has the same the value as STABWT when the RUN statement is encountered.  But the DROP statement keeps it out of the WEIGHTS dataset.

 

However, DUM is retained, meaning each observation starts out with the value in DUM generated in the preceding observation.

 

So when the "else stabwt=vwt*dum;" statement is executed, it is actually calculating stabwt as the product of VWT from the current observation and STABWT from the prior observation.  EXCEPT when the current obs is the beginning of a new patsc group, when the "stabwt=VWT;" statement is executed.

 

In other words, STABWT=VWT*lag(STABWT) except when starting a new patsc.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
sasprog
Calcite | Level 5
Thank you for explain, very helpful.

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!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 617 views
  • 0 likes
  • 2 in conversation