We examined associations between latent class (pattern of daily smoking in the first 27 days of an attempt to quit smoking) and tobacco abstinence rates at 6-months post-quit. This model used latent class membership as estimated in an unconditional model.
The text that appears in green is not part of the code; these are comments added to clarify the meaning of the code.
The first step is to generate the posterior probabilities (estimates of the probability of being in each class for each subject) from the final unconditional model.
PROC LCA DATA=libname.filename
OUTPOST=libname. OUTPOST_5;
/* Specify library for output file containing posterior probabilities of latent class membership. */
TITLE “Distal Outcome Analysis – Associations between unconditional RMLCA latent class and 6-month confirmed abstinence rates”;
NCLASS 5;
ITEMS Smoke1 – Smoke27;
CATEGORIES 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2;
CORES 6;
SEED 314728;
NSTARTS 200;
RHO PRIOR = 1;
RUN;
The second step is to merge the posterior probability data generated in the previous step to the distal outcome data file.
PROC SQL;
create table libname.Post_Distal as/* Specify library and filename for new, merged data. */
Select post.ID post.POSTLC1, post.POSTLC2, post.POSTLC3, post.POSTLC4, post.POSTLC5, post.BEST, input.zz
/* Specify that the new file should contain the ID number and posterior probabilities of membership in each of the five classes (LC1 through LC5) for each subject , along with an indicator of the best class assignment for each subject based on the maximum posterior probability across classes. Variable zz is the distal outcome (a binary indicator of 7-day point-prevalence abstinence from tobacco at 6-months post-quit) from the input file. */
From stud 4.OUTPOST_5 as post
/* Specify posterior probability file created above. */
inner join
libname.distal_outcome as input
/* Specify the library and filename for your distal outcome data. */
on post.ID = input.ID;
quit;
The third step is to run analyses on the combined posterior probability and distal outcome data, examining the marginal means of the outcome as a function of estimated latent class membership. The syntax below will generate chi square tests of differences between abstinence rates for all pairs of latent classes.
%MACRO class (col =, row= );
%DO i = 1 %TO &col;
%DO j = 2 %TO &row;
PROC FREQ data = libname.Post_Distal;
/* Use the merged datafile created in the previous step . */
TITLE ”Marginal means of 6-month abstinence by best estimate of latent class from unconditional 5-class RMLCA”;
where BEST IN (&i, &j);
table BEST *zz/ chisq missing;
RUN;
%END;
%END;
%MEND class;
% class (col = 4 row = 5);