LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (November 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 13 Nov 2000 16:20:42 -0600
Reply-To:     Walter Scott <wscott@MAIL.STATE.TN.US>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Walter Scott <wscott@MAIL.STATE.TN.US>
Subject:      Re: Getting value of PATH= option
Comments: To: rjf2@CDC.GOV
Content-Type: text/plain; charset=US-ASCII

Ronald, I was confused by your reply, until I got around to testing the macro under v8.1 (on NT 4.0). That resulted in error messages similar to those in your reply. At first glance, based on the log from the test run and the output of proc options, in v8.1 %sysfunc(getoption(path)); returns the path string enclosed in parentheses and each path 'segment' enclosed in quotes. The path string also appears to be incomplete, both in the value returned by %sysfunc(getoption(path)) and the value shown in the proc options output. In both cases the closing paren is missing as well as a path setting for BASE; BASE has to be present in all SAS installations (or, at least, such was the case through v6.12). I would expect to find a path setting for it; such is the case in v6.12. In v6.12 the %sysfunc(getoption(path)) statement returns the (apparently) full path string w/o parens or quotes. In the proc options output the individual paths are listed one per line; again w/o parens or quotes. Time to do more digging in the docs. Walter

>>> "Fehd, Ronald J." <rjf2@CDC.GOV> 13:46:31 13-Nov-00 >>> 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; >


Back to: Top of message | Previous page | Main SAS-L page