/* ReadNasal.sas: Read and re-format. This is like Nasalance1.sas but without all the proc prints. Use with %include '/folders/myfolders/441s16/Lecture/ReadNasal.sas'; */ title "Gillian DeBoer's Nasalance Data"; proc import datafile="/folders/myfolders/NasalanceTest.xls" out=wide dbms=xls replace; getnames=yes; /* Search and replace NA with 999 in the spreadsheet, because proc transpose used below will omit any columns with missing values (columns become rows in the transpose). This is critical. */ proc transpose data=wide out=long1 prefix=Subject; /* Labelling variables */ id participant; /* in the transposed data set. */ data long2; set long1; Feedback = SubjectSubheading_dail_rep; /* More infomative name */ Condition = _name_; /* Useful name of experimental condition */ Time = _n_; array Sub Subject4 -- Subject14; array id[10] ( 4 5 6 7 8 9 10 12 13 14 ); /* Optional */ j = 0; /* Give consecutive numbers to subjects */ do over Sub; j = j + 1; Participant = id[j]; /* Optional */ Nasalance = Sub[j]; if Nasalance=999 then Nasalance=.; /* Fix the missing values. */ Subject = j; output; /* Create a new case. */ end; /* Reorder the variables. This method seems a bit strange to me. */ data long2; retain Participant Condition Feedback Nasalance Time Subject; set long2; /* Keep only the variables we want. Order below does not matter.*/ keep Participant Condition Feedback Nasalance Time Subject; run; proc sort data = long2 out=long3; by Subject; /* Could sort by Time as well, but data are already in time order. */