Date: Sat, 31 Jan 2004 12:48:36 -0600
Reply-To: pudding man <pudding_man@MAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: pudding man <pudding_man@MAIL.COM>
Subject: Re: doco code
Content-Type: text/plain; charset="iso-8859-1"
It might bear mentioning that dg likely needs neither macro
nor multiple DATA steps for this application.
Using FILENAME ... PIPE and INFILE ... FILEVAR= the
code could look something like (tested):
%let dir = d:\xx_sas;
%let prefix = dum;
filename indir pipe "dir/b/l/n &dir.\&prefix*.dat";
data dir;
length fn fs $ 256;
infile indir dlm='99'x;
input fn $; *** file name ***;
fs = "&dir\" || fn; put / fs=; *** file specification ***;
infile yomama filevar = fs;
input #3 @'* Author' author :&$32.
#5 @'* Date' creation :$32.
#7 @'* Filename' filename :$32.
#9 @'* Purpose' purpose1 :&$32. /
@'*' purpose2 :&$42.
;
run;
proc print; run;
Adding the code for ODS stuff should be obvious ...
Skoal,
Pudin'
*******************************************************
***** Puddin' Man **** Pudding_Man-at-mail.com ********
*******************************************************;
"You may bury my body
down by the highwayside
so my ol' evil spirit
can get a Greyhound bus and ride."
- from "Me And The Devil", Robt Johnson, maybe 1936.
----- Original Message -----
From: dg <queanbeyan@HOTMAIL.COM>
Date: Sun, 1 Feb 2004 01:37:26 +1100
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: doco code
Resolved the issue myself at 1.15am (drowsy programming works!!) and
finalised the code..
The Code reads a standard header that I have my staff apply to all their SAS
work. It is a keyboard abbreviation attahced to the F2 key and places the
date, author, and filename in the header. It also allows for a purpose to
be keyed in. This code reads the header and generates a report based on the
author, date, filename and purpose. If anyone is interested in having a
look at the keyboard abbreviation, please let me know.
The code for the macro is as follows:
options noxwait mlogic mprint symbolgen;
%macro doco(dir,prefix);
x "dir/b/l/n &dir.\&prefix*.sas > c:\dir.txt";
filename xx 'c:\dir.txt';
data dir;
length filelst $ 100;
infile xx dlm='99'x;
input filelst $;
run;
data _null_;
set dir nobs=n;
call symput('yy'||trim(left(put(_n_,3.))), trim(left(filelst)));
if n then call symput("n",n);
run;
%do i=1 %to &n;
data new&i.(keep=author creation filename purpose);
length author creation filename purpose $ 80;
infile "&dir.\&&yy&i" expandtabs;
;
if _n_ = 1 then do;
input #3 @'* Author' author $32.
#5 @'* Date' creation $32.
#7 @'* Filename' filename $32.
#9 @'* Purpose' purpose1 $32. /
@'*' purpose2 $42.
;
if _n_ = 1;
end;
author=compress(author,':*');
creation=compress(creation,':*');
filename=compress(filename,':*');
purpose=trim(compress(purpose1,':'))||'
'||trim(compress(purpose2,':'));
if author gt ' ';
run;
%end;
data all;
set %do i = 1 %to &n; new&i. %end; ;
output;run;
ods rtf file='c:\sas programs.rtf';
proc print noobs;
run;
ods rtf close;
%mend;
%doco(c:,2004)
"dg" <queanbeyan@hotmail.com> wrote in message
news:401ba1d6$0$4259$afc38c87@news.optusnet.com.au...
> Hi there,
>
> I am trying to produce a simple doco system to read my sas programs and to
> output parts of the header of my code into a new dataset.
>
> Here is what I have got so far (partially thanks to sas-l).
>
> The code basically reads the c:\ directory for sas coded files and then
> tries to extract parts of the header text of the programs. However my
> output file 'all' does not contain details from all the files even though
> they are apparent with the call symput statements. Any ideas on how to
make
> this work would be appreciated.
>
> options noxwait mlogic mprint symbolgen;
>
> x 'dir/b/l/n c:\20*.sas > c:\dir.txt';
>
> filename xx 'c:\dir.txt';
>
> %macro doco;
>
> data dir;
>
> length filelst $ 100;
>
> infile xx dlm='99'x;
>
> input filelst $;
>
> run;
>
> data _null_;
>
> set dir nobs=n;
>
> call symput('yy'||trim(left(put(_n_,3.))),
trim(left(filelst)));
>
> if n then call symput("n",n);
>
> run;
>
>
>
> %do i=1 %to &n;
>
> %put &&yy&i;
>
> %end;
>
> data %do i = 1 %to %eval(&n-1); new&i. %end;
>
> ;
>
> %do i=1 %to %eval(&n-1);
>
> infile "c:\&&yy&i" expandtabs;
>
> %end;
>
> ;
>
>
>
> input #3 @16 author $16.
>
> #5 @16 creation $18.
>
> #7 @16 sasname $40.
>
> ;
>
> if _n_ = 1 then output;
>
> /* sasname1=compress(sasname,'*');*/
>
> /* drop sasname;*/
>
> /* output;*/
>
> run;
>
> data all;
>
> set %do i = 1 %to &n; new&i. %end; ;
>
> output;run;
>
> %mend;
>
> %doco
>
>
>
--
_______________________________________________
Get your free email from http://www.mail.com