/* Vision test results on patients with macular degeneration */ /* Vision was tested at the outset of the study, after 3 months, */ /* after 12 months, and after 24 months. The second number is the */ /* important number in Snellen */ data a; input Patient $ Group $ Gender $ Age Snellen0 $7. +1 Snellen3 $7. +1 Snellen12 $7. +1 Snellen24 $7. ; datalines; A1340 Trt M 64 6 by 60 6 by 60 2 by 60 3 by 60 B1456 Con F 57 6 by 36 6 by 36 6 by 60 6 by 60 A1332 Con F 72 6 by 36 6 by 30 6 by 18 6 by 18 C1345 Trt M 70 6 by 18 6 by 36 6 by 36 6 by 60 A0457 Con M 71 3 by 36 3 by 24 6 by 60 6 by 36 ; proc print data=a; run; /* A transpose that doesn't save all the variables */ proc sort data=a; by patient; proc transpose data=a out=out1; by patient; var Snellen0 Snellen3 Snellen12 Snellen24; proc print data=out1; run; /* A transpose that saves all the other demographics */ proc sort; by patient group gender age; proc transpose data=a out=out2; by patient group gender age; var Snellen0 Snellen3 Snellen12 Snellen24; proc print data=out2; run; /* Let's change a couple column names-prefix C since we'll change to numeric later on */ proc transpose data=a out=out3(rename=(col1=CSnellen)) name=CMonth; by patient group gender age; var Snellen0 Snellen3 Snellen12 Snellen24; proc print data=out3; run; /* And fix up Month and Snellen so they can be */ /* treated as either factors or covariates */ data out4; set out3; drop CSnellen Cmonth; Snellen=input(substr(Csnellen,6,2),2.); Month=input(substr(Cmonth,8,2),2.); proc print data=out4; run;