List only the column names of a dataset
Here's one I've used before to get a list of columns with a little bit more information, you can add the keep option as in the previous answer. This just demonstrates how to create a connection to the metadata server, in case that is useful to anyone viewing this post.
libname fetchlib meta
library="libraryName" metaserver="metaDataServerAddress"
password="yourPassword" port=1234
repname="yourRepositoryName" user="yourUserName";
proc contents data=fetchlib.YouDataSetName
memtype=DATA
out=outputDataSet
nodetails
noprint;
run;
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 ;