automagically copying and pasting variable names arthur tabachneck roger deangelis randy herbison...

30
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

Upload: adele-peters

Post on 20-Jan-2016

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

AutomagicallyCopying 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

Page 2: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

Have you ever wished that SAS provided a way for you to easily develop point-and-click methods for

accomplishing common tasks?

Page 3: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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?

Page 4: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

and, of course, the task had to be accomplished almost

automagically

Page 5: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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

Page 6: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?take advantage of some not very well known

capabilities of SAS Explorer

Page 7: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?take advantage of some not very well known

capabilities of SAS Explorer

Page 8: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?

take advantage of some not very well known capabilities of SAS Explorer

Page 9: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

such a capability is only moments away with the method described in this presentation

Page 10: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?

Click anywhere in the SAS Explorer side of the screen

Page 11: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?

Click on Tools→Options→Explorer

Page 12: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?Click on the ‘Members’ tab, the ‘Table’ Library

Member and, finally, on the ‘Edit’ Button

Page 13: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?

Click on Add

Page 14: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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

Page 15: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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; ";

Page 16: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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 screen3

Page 17: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

how?

Click on OK to exit the Table Options screen4

Page 18: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

a solutionthen, whenever you or a user right-click

on a file in the SAS Explorer window

Page 19: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

then you can paste the variable names into SAS or any other program that has copy/paste functionality

The Hotkey Driven Solution

Page 20: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

The Hotkey Driven Solutionthen you can paste the variable names into SAS or any other

program that has copy/paste functionality

Page 21: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

wouldn’t it be nice to put all of your (or your users) common tasks on that menu?

Copy Variable Names to ClipboardRun Proc ContentsGet descriptive statisticsShow all correlationsCompare groupsPrint bar chartsRun factor analysis

Action command for Proc Contents

gsubmit "proc contents data=%8b.%s;run;";

Page 22: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

For those of you who wanta non-point-and-click solution

a complete just as easy to develop hotkey-driven solution is also described in our paper

Page 23: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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;

Page 24: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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"";' "

Page 25: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

Save the assigned key assignment

In command line type: keys

3

The Hotkey Driven Solution

Page 26: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

Save the assigned key assignment

In command line type: save, then click on ‘Yes’ and ‘OK’

4

The Hotkey Driven Solution

Page 27: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

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

Page 28: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

then you can paste the variable names into SAS or any other program that has copy/paste functionality

The Hotkey Driven Solution

Page 29: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

The Hotkey Driven Solutionthen you can paste the variable names into SAS or any other

program that has copy/paste functionality

Page 30: Automagically Copying and Pasting Variable Names Arthur Tabachneck Roger DeAngelis Randy Herbison Insurance Bureau of Canada CompuCraft Inc Westat John

Coder’s CornerApril 12, 2010ForumSAS

Author Contact Information

Your comments and questions are valued and encouraged.

Contact the authors:Arthur Tabachneck, Ph.D.Director, Data ManagementInsurance Bureau of Canada2235 Sheppard Ave. EastToronto, Ontario L3T 5K9e-mail: [email protected]

John King,Ouachita Clinical Data Services, Inc.Mount Ida, ARe-mail: [email protected]

Randy Herbison,Senior Systems Analyst Westat1650 Research BoulevardRockville, MD 20850e-mail: [email protected]

Roger DeAngelisCompuCraft Inc1770 Via Petirrojo Apt ANewbury Park, CA 91320e-mail: [email protected]

Andrew Clapson Ottawa, Ontario e-mail: [email protected]

Tom AbernathyPfizer, Inc.235 E. 42nd StreetNew York, NY 10017e-mail: [email protected]