Help using Base SAS procedures

How to use proc transpose to transpose certain columns

Posts: 20

How to use proc transpose to transpose certain columns

I have this data


School NameStateSchool Code 26/07/2009 02/08/2009 09/08/2009 16/08/2009
Northwest HighIL1455606060606
Georgia HighGA14705050506

The desired output is

School NameState School Code DateAbsent
Northwest HighIL14566 26/07/20096
Northwest HighIL14556 02/08/20096
Northwest HighIL14556 09/08/20096
Northwest HighIL14556 16/08/20096
Georgia HighGA147 26/07/20095
Georgia HighGA147 02/08/20095
Georgia HighGA147 09/08/20095
Georgia HighGA147 16/08/20096
Macy HghTX45456 26/07/2009NA
Macy HghTX45456 02/08/2009NA
Macy HghTX45456 09/08/2009NA
Macy HghTX45456 16/08/2009NA

This is the code I have written

proc sort data-work.input;

by School_Name State School_Code;


proc transpose data=work.input out=work.inputModified;

by by School_Name State School_Code;


But I don't get the desired output the dates are actual variables when imported into sas the become _26_07_2009. Note there are about 185 dates and they are actual variables.

Pls Help

Respected Advisor
Posts: 3,777

Re: How to use proc transpose to transpose certain columns

The variable _NAME_ will have the variable name and if your variables have labels _LABEL_ will have the the value of that label.  You can read _NAME_ using the INPUT function to create DATE.  _LABEL_ might contain a version of date that does not need to be translated.

17         data _null_;
18            _name_ = '_26_07_2009';
19            date = input(translate(_name_,' ','_'),ddmmyy11.);
20            format date date9.;
21            put _all_;
22            run;

_name_=_26_07_2009 date=
26JUL2009 _ERROR_=0 _N_=1
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation