Generating weights in mediation analysis This mediation analysis regards how much of the social inequality (as a binary exposure) in long term sickness absence is mediated through physical work environment.
The mediator is the logarithm of the physical work environment score
(between 1 and 100 with 100 corresponding to a physically very demanding work environment) at baseline.
In this example the authors Lange et al. they state:

We can now compute the first part of the weights by using the actual
  observed values for the mediator, the predicted means, and the residual
  standard deviation (manually taken from the output of PROC GENMOD,
  in combination with the probability density function for a normal 
  distribution.

DATA newMyData;
SET newMyData;
weightDIR = PDF('normal',logphys, predM, 1.2083);
RUN;

DATA newMyData;
SET newMyData;
weightINDIR = PDF('normal',logphys, predMStar, 1.2083);
RUN;

DATA newMyData;
SET newMyData;
w = weightINDIR/weightDIR;
RUN;



*

*It's not very clear to me why they would use a normal distribution to generate direct and indirect weights?

*Why is the final weight generated as the fraction of weights of direct and indirect effects?
Many thanks..
Reference: Theis Lange, Stijn Vansteelandt, and Maarten Bekaert; A Simple Unified Approach for Estimating Natural Direct and Indirect Effects; American Journal of Epidemiology 2011.
 A: It's not very clear to me why they would use a normal distribution to generate direct and indirect weights?
Yes, they are using the command to draw a value from a normal PDF, but more importantly they are drawing this from the PDF for the fitted values they obtained in the first two steps of their estimation procedure. Those two steps being:

  
*
  
*Estimate a suitable model for the exposure conditional on confounders by using the original data set.
  
*Estimate a suitable model for the mediator conditional on exposure and baseline variables by using the original data set. 
  

Hence, the specification of the mean and standard deviation from their predicted values. Given that the dependent variable ($logphys$) was already close to normal, and because with more observations (they have over 3k) and more variables in a model, the distribution of fitted values will quickly tend toward normal, this seems to be a reasonable assumption. 
And, they do caveat this somewhat in their conclusions, advising the reader to conduct a thorough sensitivity analysis. Before drawing from your own fitted values with your own fitted data, it probably wouldn't be a bad idea to test your normality assumptions. The authors do note that, 

This can either be done by resampling from the observed exposures or by drawing from a normal distribution with the mean and standard deviation matching the observed exposure. 

In the example code you give, they take the second approach, but as they note, if you don't want to draw from the PDF, for whatever reason, you can also resample your data to draw these values. 
Why is the final weight generated as the fraction of weights of direct and indirect effects?
I'm going to assume you follow their explanation of the use of counterfactuals in a Marginal Structural Model (MSM), so I would then direct you to the second column of p. 4, where they define their stabilized weights as:
$$
w_i^c = \frac{P(M = M_i \vert A = A_i^*,C = C_i)}{P(M = M_i \vert A = A_i,C = C_i)}
$$
In this, $A_i^*$ refers to the counter-factual and thus to the indirect effect, whereas $A_i$ refers to the direct effect. Recall that $A$ is the causal predictor of interest. $M$ is the mediator, and $C$ are confounders. In the above, we therefore have 'indirect' in the numerator and 'direct' in the denominator, thus w = weightINDIR/weightDIR.  
For future readers / other answers
I think I've summarized the key points of the article as they relate to this question, but here's a link to the original. No paywall; it's open-access. 
