Return to Archive

SAS Tip of the Month
April 2008

When data is transposed it is possible to put both a label onto the transposed variable inside the TRANSPOSE procedure using the IDLABEL statememt. The following code shows how this is done:

    DATASET: VITAL_IN
    SUBJECT  TEST  TSTLABEL     TSTVALUE
     00-01   HGT   Height (cm)  175
     00-01   WGT   Weight (kg)  75
   
    proc sort data=vital_in;
       by subject;
    run;
    proc transpose data=vital_in out=vital_out (drop=_name_);
       by subject;
       id test;
       idlabel tstlabel;
       var tstvalue;
    run;
    options nocenter;
    proc print data=vital_out label;
    run;
   
                      Height    Weight
    Obs    subject     (cm)      (kg)
     1      00-01       175       75
________________________________
Updated April 1, 2008