Post by Data _null_;As a side note you can eliminate the 'Klingon' macro quoting > issues with judiucious use of %sysfunc quote and dequote.
Good point regarding QUOTE/DEQUOTE functions. Since this application
requires a data step you could avoid %SYSFUNC and the creation of
extra macro variable(s) altogether by moving more of the work to the
data step. You don't necessarily need a FILEREF created with a
FILENAME statement for example.
%let currdir = c:\docs; *user input;
data dir;
length command $256;
command = catx(' ','dir /Q/S',quote(symget('currdir')));
infile dummy pipe filevar=command end=eof
length=length truncover;
do while(not eof);
input; *need code to read DIR info;
put _infile_;
end;
stop;
run;
Thanks Data Null
for a cleaner view of this see
http://homepage.mac.com/magdelina/.Public/utl.html
later tonight pacific time
Here are a few useful macros ( a have a package of 100 sysfunc macros
on my site for download - no collisions with SAS supplied macros)
%macro sysquote(arg1);
%sysfunc(quote(&arg1))
%mend sysquote;
%macro sysdequote(arg1);
%sysfunc(dequote(&arg1))
%mend sysdequotr;
%macro SysJustInTime
(arg1);
%sysfunc(dequote(%sysfunc(dequote(%sysfunc(quote(&arg1))))));
%mend
sysjustintime;
%let
inr=rdeangel;
%let txt='delayed the resolution of &inr &sysuserid %left(%trim
( FIXUP )) " just some quoting &sysver"';
/* many datsteps macros and lines of code */
%let res=%SysJustInTime
(&txt);
%put
res=&res;
res=delayed the resolution of rdeangel rdeangel FIXUP "just some
quoting 9.1"
A couple of points on quote/dequote
The beauty of sysfunc quote/dequote is the ability to delay macro
substitution and evaluation.I know SAS is not consistent in the
application of quoting and dequoting macro variables, especially with
regex and fread/fput when used with the macro facility. I think this
method simplifies some cases of macro quoting.
One point the quote function uses double quotes. This has two
functions, one it adds double quotes around the macro variable and
most importantly it evaluates the all macro triggers. Unfortunately
this may not be what you want to do,.so it does NOT eliminate the need
for selective quoting, ie quote '%' but not '&'.
Each morniing when I get up I say to myself
1. Use the datastep and FCMP to eliminate klingon macro variable
encantations and macros. I learned this lesson from Ian.
2. Most REPORTING many standard macros can be replaced with more
FLEXIBLE NON-MACRO 9.2 code.
I have been burned too many times by simple requests that 5,000
line STANDARD macros could not do(see below)
Here are some techniques to handle the MANY simple requests that
5,000 line STANDARD macros cannot. All in 30-60 lines of NON-MACRO code
(see my site for some details).
a. Normalize the data structures as soon as possble (make long
and skinny) ie (two columns -- Question Answer - like the Oracle
response table in Oracle Clinical)) ( I learned this from Howard)
b. Use ODS output (with match_all) and procedures like tabulate
to get N(PCT) and Univariate stats(Mean(SD) at once also use
preloadfmt and completypes. You are only interested in the ODS output
datasets. Not the report.
c. Use two formats to setup page location, order on page,
Major, Minor headings and mutiple indentations (with multilabel if
needed)
d Convert the the Answer colum to character with all the
formatting you need. Add rtf contols like superscripts. An answer
cell might contain Mean(SD) ie 97.1(99.11)\{super 1}
e. Transpose the long and skinny for consumption by proc report.
f Make sure options center and landscape ot portrait are se.
g. Male sure you set outputwidth in prepage and ods rtf text=
is in sync with your template.
e. Never use across or analysis varables in proc report. use
proc report like a dumb proc print. Run proc report for each page so
that you can have different footnotes on each page. (Use percent
cellwidths - never use fixed cellwidths)
f. Set up 100%, 75% and 50% width ods templates. Set
protectspecialchars to no for all style eliments. use
outputwidth=100% in style tabel. Many other template settings. I will
post some templates on my site.
g Build a custom png300 divice driver that honors you templates
and has an array of good hardware fonts.
I will post my png300 driver on my site.
i. Imbed graphcs in proc report(like excel does). Investigate the
new span and merge functions in proc report to create a 'box' within
proc report to place your '.png' graph. (see forrestplot code for a
pre 9.2 example)