Download presentation
Presentation is loading. Please wait.
Published byAdele Peters Modified over 9 years ago
1
Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John King Tom Abernathy Andrew Clapson Ouachita Clinical Data Services, Inc. Pfizer, Inc. Ottawa, Ontario
2
Coder’s Corner April 12, 2010 Forum SAS Have you ever wished that SAS provided a way for you to easily develop point-and-click methods for accomplishing common tasks?
3
Coder’s Corner April 12, 2010 Forum SAS The present project began in response to a SAS-L post asking: Is there a way to copy and paste any table’s variable names?
4
Coder’s Corner April 12, 2010 Forum SAS and, of course, the task had to be accomplished almost automagically
5
Coder’s Corner April 12, 2010 Forum SAS and suppose that you only have base SAS but, regardless, you’re not quite a SAS guru you’d really like to impress the people you work with and/or make SAS easier to use
6
Coder’s Corner April 12, 2010 Forum SAS how? take advantage of some not very well known capabilities of SAS Explorer
7
Coder’s Corner April 12, 2010 Forum SAS how? take advantage of some not very well known capabilities of SAS Explorer
8
Coder’s Corner April 12, 2010 Forum SAS how? take advantage of some not very well known capabilities of SAS Explorer
9
Coder’s Corner April 12, 2010 Forum SAS such a capability is only moments away with the method described in this presentation
10
Coder’s Corner April 12, 2010 Forum SAS how? Click anywhere in the SAS Explorer side of the screen
11
Coder’s Corner April 12, 2010 Forum SAS how? Click on Tools→Options→Explorer
12
Coder’s Corner April 12, 2010 Forum SAS how? Click on the ‘Members’ tab, the ‘Table’ Library Member and, finally, on the ‘Edit’ Button
13
Coder’s Corner April 12, 2010 Forum SAS how? Click on Add
14
Coder’s Corner April 12, 2010 Forum SAS how? In the Explorer Options’ Action screen type the Action you want users to see: e.g., Copy Variable &Names to Clipboard 1 Copy Variable &Names to Clipboard Action Copy Variable &Names to Clipboard
15
Coder’s Corner April 12, 2010 Forum SAS 2 how? Type the Action Command you want SAS to apply: gsubmit "filename _cb clipbrd;data _null_;file _cb;dsn='%8b'||'.'||'%32b';length name $32;do dsid=open(dsn,'I') while(dsid ne 0);do i = 1 to attrn(dsid,'NVARS');name = varname(dsid,i);put name @; end; dsid = close(dsid);end;run; filename _cb clear; "; Copy Variable &Names to Clipboard gsubmit ‘filename _cb clipbrd;data _null_ filename _cb clipbrd; data _null_; file _cb; dsn='%8b'||'.'||'%32b'; length name $32; do dsid=open(dsn,'I') while(dsid ne 0); do i = 1 to attrn(dsid,'NVARS'); name = varname(dsid,i); put name @; end; dsid = close(dsid); end; run; filename _cb clear; Action Command gsubmit "filename _cb clipbrd;data _null_;file _cb;dsn='%8b'||'.'||'%32b'; length name $32;do dsid=open(dsn,'I') while(dsid ne 0);do i = 1 to attrn(dsid, 'NVARS');name = varname(dsid,i);put name @; end; dsid = close(dsid);end; run; filename _cb clear; ";
16
Coder’s Corner April 12, 2010 Forum SAS Copy Variable &Names to Clipboard how? Copy Variable &Names to Clipboard gsubmit ‘filename _cb clipbrd;data _null_ Click on OK to exit the Add Action screen 3
17
Coder’s Corner April 12, 2010 Forum SAS how? Click on OK to exit the Table Options screen 4
18
Coder’s Corner April 12, 2010 Forum SAS a solution then, whenever you or a user right-click on a file in the SAS Explorer window
19
Coder’s Corner April 12, 2010 Forum SAS then you can paste the variable names into SAS or any other program that has copy/paste functionality The Hotkey Driven Solution
20
Coder’s Corner April 12, 2010 Forum SAS The Hotkey Driven Solution then you can paste the variable names into SAS or any other program that has copy/paste functionality
21
Coder’s Corner April 12, 2010 Forum SAS wouldn’t it be nice to put all of your (or your users) common tasks on that menu? Copy Variable Names to Clipboard Run Proc Contents Get descriptive statistics Show all correlations Compare groups Print bar charts Run factor analysis Action command for Proc Contents gsubmit "proc contents data=%8b.%s;run;";
22
Coder’s Corner April 12, 2010 Forum SAS For those of you who want a non-point-and-click solution a complete just as easy to develop hotkey-driven solution is also described in our paper
23
Coder’s Corner April 12, 2010 Forum SAS Type and save the following SAS program (e.g., as c:\copy.sas): 1 The Hotkey Driven Solution filename _cb clipbrd; data _null_; window DSN rows=8 columns=80 irow=1 icolumn=2 color=black #2 @3 'Enter 1 or 2 level data set name: ‘ color=gray dsn $41. required=yes attr=underline color=yellow; display DSN blank; file _cb; length name $32; do dsid = open(dsn,'I') while(dsid ne 0); do i = 1 to attrn(dsid,'NVARS'); name = varname(dsid,i); put name @; end; dsid = close(dsid); end; stop; run; filename _cb clear; filename _cb clipbrd; data _null_; window DSN rows=8 columns=80 irow=1 icolumn=2 color=black #2 @3 'Enter 1 or 2 level data set name: ‘ color=gray dsn $41. required=yes attr=underline color=yellow; display DSN blank; file _cb; length name $32; do dsid = open(dsn,'I') while(dsid ne 0); do i = 1 to attrn(dsid,'NVARS'); name = varname(dsid,i); put name @; end; dsid = close(dsid); end; stop; run; filename _cb clear;
24
Coder’s Corner April 12, 2010 Forum SAS Assign a key to run the code In command line type: keydef "CTL F11" "gsubmit '%inc ""c:\copy.sas"";' " 2 The Hotkey Driven Solution keydef "CTL F11" "gsubmit '%inc ""c:\copy.sas"";' "
25
Coder’s Corner April 12, 2010 Forum SAS Save the assigned key assignment In command line type: keys 3 The Hotkey Driven Solution
26
Coder’s Corner April 12, 2010 Forum SAS Save the assigned key assignment In command line type: save, then click on ‘Yes’ and ‘OK’ 4 The Hotkey Driven Solution
27
Coder’s Corner April 12, 2010 Forum SAS Then, whenever you or a user enters the assigned key they will be asked to ‘Enter 1 or 2 level data set name:’ The Hotkey Driven Solution
28
Coder’s Corner April 12, 2010 Forum SAS then you can paste the variable names into SAS or any other program that has copy/paste functionality The Hotkey Driven Solution
29
Coder’s Corner April 12, 2010 Forum SAS The Hotkey Driven Solution then you can paste the variable names into SAS or any other program that has copy/paste functionality
30
Coder’s Corner April 12, 2010 Forum SAS Author Contact Information Your comments and questions are valued and encouraged. Contact the authors: Arthur Tabachneck, Ph.D. Director, Data Management Insurance Bureau of Canada 2235 Sheppard Ave. East Toronto, Ontario L3T 5K9 e-mail: atabachneck@ibc.ca John King, Ouachita Clinical Data Services, Inc. Mount Ida, AR e-mail: ouachitaclinicaldataservices@gmail.com Randy Herbison, Senior Systems Analyst Westat 1650 Research Boulevard Rockville, MD 20850 e-mail : RandyHerbison@westat.com Roger DeAngelis CompuCraft Inc 1770 Via Petirrojo Apt A Newbury Park, CA 91320 e-mail: xlr82sas@aol.com Andrew Clapson Ottawa, Ontario e-mail: andy_clapson@hotmail.com Tom Abernathy Pfizer, Inc. 235 E. 42 nd Street New York, NY 10017 e-mail: tom.abernathy@pfizer.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.