BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
csc
Calcite | Level 5 csc
Calcite | Level 5

I have used the following procedure (from an old SAS proceedings 046-2010) to copy variable names to the clipboard in SAS V9.2:

Click on the Explorer window.

Tools/Options/Explorer/Members/Table/Edit

Add new entry.

Copy Variable &Names to Clipboard

gsubmit "filename _cb clipbrd;data _null_;file _cb;dsn='%8b'||'.'||'%32b';length N $32;do dsid=open(dsn,'I') while(dsid ne 0);do i=1 to attrn(dsid,'NVARS');N=', '||varname(dsid,i);put N;en;dsid=close(dsid);end;run;filename _cb clear;";

Is there a way to do the same in EG 4.3?

I know I can click on properties, columns and click copy to Clipboard, but I get a whole lot more than just the column names separated by commas.

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

@csc,

 

And...here's the task! Glad that I was able to demo it for you in Las Vegas at the Analytics 2015 conference.  It's events like this that can make things happen!

 

You can 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.

 

When you add the task, you'll see three new entries under Tools->Add-In->Data Utilities.

 

copycols.png

Each one copies the column names (variable names) from the active SAS data set in a slightly different format: CSV on one line, CSV on multiple lines, and just a straight list with names one-per-line, no separator.

 

Enjoy!

Chris

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

View solution in original post

5 REPLIES 5
LinusH
Tourmaline | Level 20

There are many ways to get the variable name from a SAS data set (in EG), but the example you provide doesn't for obvious reasons: the clipboard is on the client (where EG is executing), but the SAS code is executing on the server, and are not client aware.

To help with an alternative solution, you can help by telling when, and how you wish to use the variable lists.

Data never sleeps
csc
Calcite | Level 5 csc
Calcite | Level 5

Often I am using a file that I did not create.  I then need a variety of fields from that file in subsequent code.  The PC SAS code above allows me to right click on the file in Explorer and choose "Copy Variable names to Clipboard", which will give me the following when I paste:

, variable1

, variable2
, variable3

, etc,

Being a long time PC SAS user and new to EG, I thought for sure there was a way to replicate this shortcut.

A custom task sounds interesting.

Tom
Super User Tom
Super User

Looks like you need a custom task in Enterprise Guide.  Perhaps Chris@SAS can show use how?

ChrisHemedinger
Community Manager

Hi @csc,

 

Great to see you at Analytics 2015.  As we discussed (and I'm sharing here for the group), you might be able to use this data set->DATA step custom task to accomplish this.  Not sure that it's quite as easy as what you want, but it's a start.

 

Otherwise, it's a good idea for a specific custom task.  I'll add that to my (growing) list of useful ideas.

 

Chris

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
ChrisHemedinger
Community Manager

@csc,

 

And...here's the task! Glad that I was able to demo it for you in Las Vegas at the Analytics 2015 conference.  It's events like this that can make things happen!

 

You can 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.

 

When you add the task, you'll see three new entries under Tools->Add-In->Data Utilities.

 

copycols.png

Each one copies the column names (variable names) from the active SAS data set in a slightly different format: CSV on one line, CSV on multiple lines, and just a straight list with names one-per-line, no separator.

 

Enjoy!

Chris

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 9809 views
  • 1 like
  • 4 in conversation