Date: Sat, 17 Oct 2009 14:19:45 -0700
Reply-To: xlr82sas <xlr82sas@AOL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: xlr82sas <xlr82sas@AOL.COM>
Organization: http://groups.google.com
Subject: Re: Weekend Challenge - Keyboard Macros
Content-Type: text/plain; charset=ISO-8859-1
On Oct 17, 9:55 am, "nina" <s...@mailinator.com> wrote:
> here's how I used it, with automate 5 and sas combined
>
> automate hotkey is F11, triggers universally by first looking to see if SAS ide is in
> focus
>
> the trigger runs this in a couple seconds and dumps the last submitted dataset
> variables into a keep list
>
> <AMVARIABLE NAME="fAgeInSeconds">999999</AMVARIABLE>
> <AMLOOPFILES FOLDER="E:\SASTemp" RESULTVARIABLE="fileread" SUBFOLDERS="YES"
> INCLUDE="*.sas7bdat">
> <AMSET VARIABLENAME="fAgeInSeconds">%DateDiff("s",
> FileDateTime(fileread), Now())%</AMSET>
> <AMIF EXPRESSION="%fAgeInSeconds < minage%">
> <AMSET VARIABLENAME="minage">%fAgeInSeconds%</AMSET>
> </AMIF>
> <AMSET VARIABLENAME="linevalue">%Mid(fileread, 1,
> InstrRev(fileread,"\"))%</AMSET>
> <AMSET VARIABLENAME="strvalue">%Mid(fileread, Instr(fileread,linevalue) ,
> Len(fileread) - Instr(fileread,linevalue) )%</AMSET>
> <AMREPLACE TEXT="%strvalue%" FIND="%linevalue%" RESULTVARIABLE="linevalue">
> <AMREPLACE TEXT="%linevalue%" FIND=".sas7bda" RESULTVARIABLE="linevalue">
> <AMIF EXPRESSION="%fAgeInSeconds% <= %minage%">
> <AMSET VARIABLENAME="minfile">%linevalue%</AMSET>
> </AMIF>
> </AMLOOP>
> <AMIF EXPRESSION="%Len(minfile) < 1%">
> <AMMESSAGEBOX WINDOWTITLE="Create something" ICON="information">No dataset found
> </AMMESSAGEBOX>
> <AMSTOPTASK>
> </AMIF>
> <AMVARIABLE NAME="rp">]"</AMVARIABLE>
> <AMVARIABLE NAME="lp">"[</AMVARIABLE>
> <AMFILEWRITE FILE="E:\temp\listvarnames.sas" APPEND="NO">%%global namelist libname
> memname;
> %%let libname=WORK;
> %%let memname=%minfile%;
> proc sql noprint;
> select name into :namelist
> separated by ' '
> from dictionary.columns
> where libname=upcase</AMFILEWRITE>
> <AMFILEREAD FILE="E:\temp\listvarnames.sas" RESULTVARIABLE="fileread">
> <AMWINDOWFOCUS WINDOWTITLE="SAS" WINDOWCLASS="SAS aws">
> <AMKEYDOWN CTRL=YES>
> <AMSENDKEY>n</AMSENDKEY>
> <AMKEYUP CTRL=YES>
> <AMPAUSE SCALAR="1">
> <AMSENDKEY DOS="YES">%fileread%</AMSENDKEY>
> <AMSENDKEY METHOD="paste">(</AMSENDKEY>
> <AMSENDKEY>"&libname."
> </AMSENDKEY>
> <AMSENDKEY METHOD="paste">)</AMSENDKEY>
> <AMSENDKEY>and memname=upcase</AMSENDKEY>
> <AMSENDKEY METHOD="paste">(</AMSENDKEY>
> <AMSENDKEY>"&memname."</AMSENDKEY>
> <AMSENDKEY METHOD="paste">)</AMSENDKEY>
> <AMSENDKEY>;
> quit;
> filename clippy clipbrd;
> data _null_;
> file clippy;
> put "&namelist.";
> run;</AMSENDKEY>
> <AMSENDKEY>{F3}</AMSENDKEY>
> <AMPAUSE SCALAR="2">
> <AMWINDOWFOCUS WINDOWTITLE="SAS" WINDOWCLASS="SAS aws">
>
> <AMSENDKEY>{CTRL}{F4}</AMSENDKEY>
> <AMSENDKEY>{ALT}N</AMSENDKEY>
> <AMSENDKEY METHOD="paste"> (</AMSENDKEY>
> <AMSENDKEY>keep=</AMSENDKEY>
> <AMCLIPBOARDPASTE>
> <AMSENDKEY METHOD="paste"> )
> </AMSENDKEY>
I think you can do this with simple command macro code and the un-
enhanced editor
I think you can take this a little further
I highlight a dataset in the program editor and hit pf8 and the output
window will contain a proc contents of the highlighted dataset.
It should e easy to write the variables to the clipboard and then
'cntl-v' to paste them.
see
http://homepage.mac.com/magdelina/.Public/utl_tipweb.txt
T001130 POOR MANS VERSIONING IN SAS
T002580 SAS KEYBOARD ABREVIATIONS BY WAY OF COMMAND MACROS
T001130 POOR MANS VERSIONING IN SAS
F8 store;note;notesubmit '%uxpcon; /* contents highlighted
dataset */
You can simplify the code below if you use just one operating system,
ie do not use sas connect
%macro uxpcon;
filename clp clipbrd ;
data _null_;
infile clp;
input;
put _infile_;
call symputx('argx',_infile_);
run;
dm "out;clear;";
%syslput argx=&argx;
rsubmit;
footnote;
title "Contents for highlighted &argx";
options nocenter;
proc contents data=&argx position;
run;
title;
endrsubmit;
dm "out;top";
%mend uxpcon;