As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.
Here are some tips for How to share your SAS knowledge with your professional network.
Tip of the Day:September 29
sasCommunity Tip of the Day
As part of the decommissioning effort for sasCommunity.org this article/tip has been migrated to communities.sas.com.
The new home for this article/tip is September 29 (https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Easy-Way-to-Get-All-Variable-Names-From-a-Dataset/m-p/475815#M176)
%macro getvars(dsn); %global vlist; proc sql; select name into :vlist separated by ' ' from dictionary.columns where memname = upcase("&dsn"); quit; %mend;
This creates a macro variable called &vlist that will contain the names of all the variables in your dataset, separated by a space. If you want commas between the variable names, all you have to do is change the 'separated by' value from ' ' to ', '. The use of the upcase function in the where statement avoids problems with someone passing the dataset name in the wrong case. The global statement is needed since the macro variable created will not necessarily be available outside the macro without defining it as global.
Submitted by Spm. Contact me at my Discussion Page.
Feel free to comment on this tip.