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.
@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.
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
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.
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.
Looks like you need a custom task in Enterprise Guide. Perhaps Chris@SAS can show use how?
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
@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.
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
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.