Copy SAS variable names to the clipboard in SAS Enterprise Guide


I recently met SAS user "CSC" at the Analytics 2015 conference. It might be generous to say that he's an avid user of SAS Enterprise Guide; it's probably more accurate to say that he's now accustomed to the tool and he's once again productive. But he still misses some features from his PC SAS days, including this one.

He wants to be able to copy just a list of SAS variables names from a SAS data set, so that he can then paste them into a SAS program (or another document). In PC SAS he had a simple GSUBMIT sequence that captured the names and "copied" them to the Windows clipboard with FILENAME CLIPBRD. That does not work in SAS Enterprise Guide, because SAS doesn't have direct access to the clipboard on your local machine.

CSC posted his question to the SAS Enterprise Guide community, and Tom suggested that a custom task might help. Good answer, but there it sat until CSC and I met in person this week in Las Vegas. After a short discussion and a personal plea, I was able to create the task in about 30 minutes.

Actually, it's three tasks, to cover three variations of the "Paste" operation. One supports a CSV-style, another supports CSV over multiple lines, and a third produces just a straight list on separate lines with no commas.


You can download and try this custom task too. It works with SAS Enterprise Guide 4.3 and later. Download the task from the SAS support site as a ZIP file. The instructions for installation and use are in the README.txt in the ZIP file.

Related articles


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. Another hit! This has been badly needed for a long time. I have used numerous little work arounds to do this, but none were as slick as how I used to do it in PC SAS. Thanks.

  2. Hi Chris, a nice tool. As a SAS coder you may need a list of variables with commas (for SQL, lists in functions) or without (VAR, DROP/KEEP..) Could this variation be considered for a future enhancement ?

    • Chris Hemedinger
      Chris Hemedinger on

      Gee whiz Peter, some people are never satisfied. Did you not see that the task offers 3 variations already? 2 with commas, 1 without? Are you looking for a fourth variation that produces a list of variables all on one line, without commas?

  3. Chris

    Thanks for another great tool that makes live with SAS easier.

    For SQL use, there is another way to get the list of variables using the following code:
    Proc SQL feedback noexec; select * from as c; quit;
    This will give also a list to be used in a SQL query.

  4. Hi Chris,

    Thanks Chris.

    To users of older versions of SAS Enterprise Guide 4.3 and/or users who do not have the privilege to install are finding it hard.

    I have an alternative way to get the list of variable names from a SAS data set.
    Right click on the dataset icon then select 'properties'.
    From left pane of properties box, select 'Columns'; click the 'copy to clipboard' button then paste to wherever is convenient.

  5. I've always gotten around this by setting up an abbreviation "ccc" that does proc contents (keep=name) noprint out=c; then I can select the column and copy.

Back to Top