Search code examples
sas

List only the column names of a dataset


I am working on SAS in UNIX env and I want to view only the column name of a dataset. I have tried proc contents and proc print but both of them list a lot of other irrevelant information that I do not want as it fills up my putty screen and the information ultimately is lost.

I also tried to get this thing frm the sas metadata but that is not working either. I tried :

  2? proc sql;
  select *
 from dictionary.tables
 where libname='test' and memname='sweden_elig_file_jul';
quit;
  5?
NOTE: No rows were selected.

  6?
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.27 seconds
      cpu time            0.11 seconds

Solution

  • You're using the wrong dictionary table to get column names...

    proc sql ;
      select name 
      from dictionary.columns
      where memname = 'MYDATA'
      ;
    quit ;
    

    Or using PROC CONTENTS

    proc contents data=mydata out=meta (keep=NAME) ; 
    run ; 
    proc print data=meta ; run ;