Date: Mon, 13 Nov 2000 15:02:16 EST
Reply-To: Bernard Tremblay <imaginasys@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Bernard Tremblay <imaginasys@HOTMAIL.COM>
Subject: Re: Getting value of PATH= option
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Ronald,
Classical case of MACRO processor interfering with your code.
You have a macro expression between quotes wich contains quotes ... Results
: incorrect SAS code . You should quote the macro value with the function
%quote(&Y) or put double quotes on each side of the macro variable ( I
think that ""&Y"" would work or %"&Y%").
Regards,
\\\|///
\\ - - //
( @ @ )
+-----oOOo-(_)-oOOo--+-----------------------------------+
| Bernard Tremblay | |
| CSST | Tel: (418) 528-9313 |
| | Fax: (418) 528-1493 |
| | Int: Bernard.Tremblay@csst.qc.ca |
+----------------------------+---------------------------+
| Imaginasys enr | Res: (418) 658-1411 |
| | Int: bertrem@videotron.ca |
| | Hot: imaginasys@hotmail.com |
+--------------Oooo--+-----------------------------------+
oooO ( )
( ) ) /
\ ( (_/
\_)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>From: "Fehd, Ronald J." <rjf2@CDC.GOV>
>Reply-To: "Fehd, Ronald J." <rjf2@CDC.GOV>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Getting value of PATH= option
>Date: Mon, 13 Nov 2000 14:46:31 -0500
>
>very strange stuff here:
>I have added debugging %put statements
>
>%LET TESTING =1;
>%let y=%sysfunc(getoption(path)); /* Get the PATH */
>%IF &TESTING %THEN %PUT Y<&Y.>;
>
>and find that
>
>Y<( "!sasroot\core\sasexe" "!sasext0\access\sasexe" [snippage occurs]
>has an open paren, which is unremovable via %substr
>
>1222 %IF "%substr(&Y,1,1)" eq "(" %THEN %LET Y = %substr(&Y,2);
>
>NOTE: One or more missing close parentheses have been supplied for the
>%SUBSTR function.
>ERROR: Macro function %SUBSTR has too few arguments.
>ERROR: A character operand was found in the %EVAL function or %IF condition
>where a numeric
> operand is required. The condition was: "%substr(&Y,1,1)" eq "("
>ERROR: The macro SPLTPTHB will stop executing.
>
>used up my R&D testing time today
>
>Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
>OpSys: WinNT Ver: 8.1
>---> cheerful provider of UNTESTED SAS code!*! <---
>remember perspective: the error is not always where it seems to occur! --
>RJF2
>
>
> > -----Original Message-----
> > From: Walter Scott [mailto:wscott@MAIL.STATE.TN.US]
> > Sent: Monday, November 13, 2000 11:37 AM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Re: Getting value of PATH= option
> >
> >
> > All,
> > I am sorry about the long delayed response to everyone.
> > Thanks to Nancy Brucken, Ron Fehd, and Richard Graham for
> > getting me pointed in the right direction (using
> > %sysfunc(sysget(path));) and Andreas Grueninger who, this
> > morning, generously provided some comparison code.
> > It took me some time to settle on which approach to
> > take. I settled on a macro to run in Base SAS (as opposed to
> > SCL). After that it took until Friday evening (and one
> > complete re-write) to get a nice solution and get it working.
> > Also, thanks to the thread on the proper specification of
> > the substr() function; even after looking up the details on
> > the macro version of this function I had slipped into the
> > incorrect usage.
> > In hopes that it might be of use to others and that
> > there are no major bugs remaining I'm including my code
> > below. Please note that this code crashes SAS on Windows 95.
> >
> > Thanks Again,
> >
> > Walter
> >
> >
> > /* NOTE: This code is not fully tested! */
> >
> > options altlog='c:\sas612.log';
> >
> > %global nrofvars z;
> > %let segvars=;
> >
> > %macro spltpthb(segsize); /* NOTE: Crashes
> > SAS on Win95 */
> > %let y=%sysfunc(getoption(path)); /* Get the PATH */
> > %let pathlen=%length(&y); /* Determine
> > its length */
> > %let nrofvars=%sysevalf((&pathlen/&segsize),ceil); /*
> > Determine nr of vars needed */
> > %do i=1 %to &nrofvars; /* Break PATH
> > into segments */
> > %global path&i; /* Create var
> > for this segment */
> > %let start=%eval((&i-1)*&segsize+1); /* Calc START
> > position of segemnt */
> > %let stop=%eval(&i*&segsize); /* Calc STOP value */
> > %let seglen=%sysfunc(min(&segsize,&pathlen-&start+1));
> > /* Don't reach beyond end of PATH */
> > %let path&i=%substr(&y,&start,&seglen); /* "clip'
> > out the path seg */
> > %let segvars=&segvars."path&i";
> > %if &i~=&nrofvars %then %let segvars=&segvars,;
> > %put _user_; %put;
> > %end;
> > %mend;
> >
> > %spltpthb(80);
> >
> > options symbolgen;
> > data path/*(keep=path)*/;
> > *%spltpthb;
> > format pathseg $char200. path $char100. var $8.;
> > pathcnt=symget('nrofvars');
> > do var=&segvars;
> > if length(trim(pathseg))<50
> > then pathseg=left(trim(pathseg)||symget(var)); /* Pull
> > in the first/next segment */
> > do until(not z);
> > y=index(pathseg,':'); /* Get location of 1st ':' */
> > substr(pathseg,y,1)='*'; /* Change 1st colon to asterisk */
> > z=index(pathseg,':'); /* Get location of 2nd colon */
> > substr(pathseg,y,1)=':'; /* Set the '*' back to ':' */
> > if not z then leave; /* If there's not another
> > path, quit this loop */
> > path=substr(pathseg,y-1,z-2); /* Get the path */
> > pathseg=substr(pathseg,z-1); /* Cut the path from
> > remainder of paths string */
> > output;
> > end;
> > end;
> > /* If there's anything leftover in pathseg, it should be a full path
> > and should be output also */
> > if length(trim(pathseg)) then do;
> > path=pathseg;
> > output;
> > end;
> > run;
> >
> > title 'Results of using %spltpthb';
> > proc print data=path;
> > run;
> > option nosymbolgen;
> >
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Share information about yourself, create your own public profile at
http://profiles.msn.com.
|