I attended PharmaSUG China 2016 in Beijing last month, along with my line manager. There were a large number presentations this year. One presentation made a deep impression on me. The presenter shared some useful tips on presentation, such as automagically opening dataset and copying variable value. The source code is not available, so I created three small macros to accomplish these common tasks.
- %markdsn, automagically opens the dataset selected.
- %markcode, runs the selected code and automagically opens the last created dataset
- %vvalue, automagically copies variable value.
%macro vvalue(); gsubmit ' dm "wcopy"; filename clip clipbrd; data _null_; infile clip; input; call symputx("var", _INFILE_); run; filename clip clear; proc sql noprint; select distinct &var into :varlst separated by "@" from &syslast ; quit; data _null_; if not symexist("increment") then call symputx("increment", 1, "g"); else call symputx("increment", 1 + input(symget("increment"), best.), "g"); run; filename clip clipbrd; data _null_; file clip; length value $32767; if &increment <= countw("&varlst", "@") then value=scan("&varlst", &increment, "@"); else value=scan("&varlst", countw("&varlst", "@"), "@"); put value; run; filename clip clear;'; %mend vvalue;
Prerequisites:
- Store the macros in an autocall library
- In command line type below commands to assign keys to evoke these macros
keydef 'F9' '%markdsn' keydef 'F10' '%markcode' keydef 'F11' '%vvalue'
Usage:
- Select dataset name and then press F9
- Mark some code and then press F10
- Select variable name and then press F11, repeat the above process until getting the desired value