Skip past navigation to main part of page
 
Melbourne Institute Homepage
---

SAS program to create wide longitudinal file

/*Example SAS program to create unbalanced and balanced wide files*/
/*Created by Paul Agius 2/11/2006 (Updated by: Nicole Watson)*/
 
/*Setting libraries*/
libname wave1 'E:\Release 6.0\a60c'; run;
libname wave2 'E:\Release 6.0\b60c'; run;
libname wave3 'E:\Release 6.0\c60c'; run;
libname wave4 'E:\Release 6.0\d60c'; run;
libname wave5 'E:\Release 6.0\e60c'; run;
libname wave6 'E:\Release 6.0\f60c'; run;
 
/*Load the library of formats required for the datasets*/
libname library 'E:\Release 6.0\formats'; run;
/*Sorting files by xwaveid for merging*/
proc sort data = wave1.combined_a60c out=w1;
by xwaveid;
proc sort data = wave2.combined_b60c out=w2;
by xwaveid;
proc sort data = wave3.combined_c60c out=w3;
by xwaveid;
proc sort data = wave4.combined_d60c out=w4;
by xwaveid;
proc sort data = wave5.combined_e60c out=w5;
by xwaveid;
proc sort data = wave6.combined_f60c out=w6;
by xwaveid;
proc sort data = wave6.master_f60c out=master;
by xwaveid;
run;
 
/*Creating unbalanced data file*/
data wide_UNBALANCED;
merge w1 w2 w3 w4 w5 w6 master;
by xwaveid;
run;
/*Creating balanced data file for interviewed persons*/
data wide_BALANCED;
set wide_UNBALANCED;
if (afstatus = 1 or afstatus = 2) and
(bfstatus = 1 or bfstatus = 2) and
(cfstatus = 1 or cfstatus = 2) and
(dfstatus = 1 or dfstatus = 2) and
(efstatus = 1 or efstatus = 2) and
(ffstatus = 1 or ffstatus = 2);
run;

 

top of pagetop of page

HILDA Contact us

Contact the University : Disclaimer & Copyright : Privacy : Accessibility