Desktop productivity for business analysts and programmers

Copy Variable Names to Clipboard in EG

Accepted Solution Solved
Reply
Occasional Contributor csc
Occasional Contributor
Posts: 5
Accepted Solution

Copy Variable Names to Clipboard in EG

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.


Accepted Solutions
Solution
‎12-08-2015 12:05 PM
Community Manager
Posts: 2,696

Re: Copy Variable Names to Clipboard in EG

@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

 

View solution in original post


All Replies
Esteemed Advisor
Posts: 5,198

Re: Copy Variable Names to Clipboard in EG

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
Occasional Contributor csc
Occasional Contributor
Posts: 5

Re: Copy Variable Names to Clipboard in EG

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.

Super User
Super User
Posts: 6,348

Re: Copy Variable Names to Clipboard in EG

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

Community Manager
Posts: 2,696

Re: Copy Variable Names to Clipboard in EG

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

Solution
‎12-08-2015 12:05 PM
Community Manager
Posts: 2,696

Re: Copy Variable Names to Clipboard in EG

@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

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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