how to restructure cohort-sequential variables with multiple imputation

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

how to restructure cohort-sequential variables with multiple imputation

I have collected five waves of data in the fall and spring from children in grades 4 and 5 at baseline. I am trying to restructure my imputed dataset into a cohort-sequential format based upon the SAS code in the Malti paper (attached) so that it forms a trajectory of victimization among children in grades 4-7. I will be using proc transpose in SAS 9.4 to change it into long format to conduct growth curve modeling. I'm not sure if I'm making many errors along the way or where the imputation line goes. Here is what I have so far:

 

proc mi data=work.thesis seed=54321 nimpute=100 out=VICIMPUTE;

var sex TTPhyVic_1 TTPhyVic_2 TTPhyvic_3 TTPhyVic_4 TTPhyVic_5 Safe_W1 Safe_W2 Safe_W3 Safe_W4 Safe_W5; *Level 1 variables - physical victimization; within person centered safety;

run;

 

proc freq data=VICIMPUTE;

tables _imputation_ / missing; run;

 

*restructure dataset for grades 3-6 using imputed variable to create cohort-sequential variables using Marti paper;

DATA vicimpute; *I think I am missing a step here;

*SET vicimpute;

*BY _IMPUTATION_; *is this needed here?;

 

*Level 1;

IF cgrade_2=4 then do; *Physical victimization (DV) for grade 3 cohort;

PV3s = TTPhyVic_1;

PV4f = TTPhyVic_2;

PV4s = TTPhyVic_3;

PV5f = TTPhyVic_4;

PV5s = TTPhyVic_5;

END;

 

IF cgrade_2=5 then do; *Physical victimization (DV) for grade 4 cohort;

PV4s = TTPhyVic_1;

PV5f = TTPhyVic_2;

PV5s = TTPhyVic_3;

PV6f = TTPhyVic_4;

PV6s = TTPhyVic_5;

END;

 

IF cgrade_2=4 then do; *Safety (Within person Centered TVC Level 1) for grade 3 cohort;

Safe3s = Safe_W1;

Safe4f = Safe_W2;

Safe4s = Safe_W3;

Safe5f = Safe_W4;

Safe5s = Safe_W5;

END;

 

IF cgrade_2=5 then do; *Safety (Within person Centered TVC Level 1) for grade 4 cohort;

Safe4s = Safe_W1;

Safe5f = Safe_W2;

Safe5s = Safe_W3;

Safe6f = Safe_W4;

Safe6s = Safe_W5;

END;

 

*Level 2;

IF cgrade_2=4 then do; *sex boys = 0(between person Level 2) for grade 3 cohort;

sex3s = sex;

sex4f = sex;

sex4s = sex;

sex5f = sex;

sex5s = sex;

END;

 

IF cgrade_2=5 then do; *Sex boys = 0 (between person Level 2) for grade 4 cohort;

sex4s = sex;

sex5f = sex;

sex5s = sex;

sex6f = sex;

sex6s = sex;

END;

 

DROP TTPhyVic_1 TTPhyVic_2 TTPhyvic_3 TTPhyVic_4 TTPhyVic_5 sex Safe_W1 Safe_W2 Safe_W3 Safe_W4 Safe_W5; Run; *drop the original variables since they are restructured;

 

*Flip new cohort dataset from wide to long;

PROC TRANSPOSE

DATA=vicimpute OUT=vicimpute.long NAME=Pvic sex Safe;

VAR PV3s-PV6s sex3s-sex6s safe3s-safe6s;

BY idchild;

BY _imputation_;

RUN;

 

Many thanks!

 


Accepted Solutions
Solution
‎04-04-2016 07:12 PM
Super User
Posts: 19,878

Re: how to restructure cohort-sequential variables with multiple imputation

Posted in reply to cpolihronis

I highly suggest doing this in stages. As is, with your code I see several issues - you have your SET statement commented out?

But you also haven't specified what exactly you're having difficulty with.

 

I would recommend breaking this into each data/proc, get that running and go from there. If you need help with a specific section, then ask a specific question. As is, this is hard to follow or provide comments - especially since you haven't provided sample data. 

 

You don't do any BY group prcoessing (no first. or last. ) so you don't need a BY statement.

 

View solution in original post


All Replies
Solution
‎04-04-2016 07:12 PM
Super User
Posts: 19,878

Re: how to restructure cohort-sequential variables with multiple imputation

Posted in reply to cpolihronis

I highly suggest doing this in stages. As is, with your code I see several issues - you have your SET statement commented out?

But you also haven't specified what exactly you're having difficulty with.

 

I would recommend breaking this into each data/proc, get that running and go from there. If you need help with a specific section, then ask a specific question. As is, this is hard to follow or provide comments - especially since you haven't provided sample data. 

 

You don't do any BY group prcoessing (no first. or last. ) so you don't need a BY statement.

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 334 views
  • 0 likes
  • 2 in conversation