Reputation: 2059
I often want to paste all of the variable names of a dataset into one column in an Excel file.
proc contents data=mydata varnum short;
run;
will give me the names separated by spaces in ODS. I run text-to-columns and then paste-transpose the results to get the format that I want.
I want that same output, but separated by line breaks instead of spaces so that I can easily paste them into a single column in Excel.
Thanks for your suggestions, pT
Upvotes: 3
Views: 594
Reputation: 1283
If you want to use proc contents, make it output to a dataset:
proc contents data=mydata noprint out=mydata_varnames (keep=name);
run;
Then either open the dataset and copy-paste, or export the data to a file using proc export. (e.g., a csv file. i'm not a fan of exporting directly to xls)
Upvotes: 2
Reputation: 2275
the table view vcolumn in the library SASHELP will give you the what you need. This table view is automatically generated by sas.
proc sql noprint;
create table vars as
select name
from sashelp.vcolumn
where libname = upper("work")
and
memname = upper("table1")
;
quit;
where work is your library and table1 is the table you want the variables from
Upvotes: 2