LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 1997, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 4 Mar 1997 07:53:33 GMT
Reply-To:   Andrew James Llwellyn Cary <ajlcary@IX.NETCOM.COM>
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   Andrew James Llwellyn Cary <ajlcary@IX.NETCOM.COM>
Organization:   Cary Consulting Services
Subject:   Re: Trailing Blanks

The problem is the default length of your macro variable as defined in the SQL is the length of the PATH variable in the view (char 80). This length is propagated. When you use a compress, trim, or scan SAS thoughtfully removes the blanks and then refills the variable to the length of 80 with blanks (after all that's how long you told SAS the variable was!). Since when setting the macro variable to itself will ignore trailing blanks and give you a shorter value.

The code below will set the macro variable to the correct length at each invocation without trailing blanks.

proc sql; select length(path) into :lenpath from SASHELP.VSLIB where upcase(libname)='WORK'; select path length=&lenpath into :worklib from sashelp.vslib where upcase(libname)='WORK'; quit;

AJL Cary

Ronald Max Atwood Jr <matwood@IX.NETCOM.COM> wrote in article <199703040024.SAA27670@dfw-ix1.ix.netcom.com>... > I am coding a program where it would be very helpful to have the path > to the SAS work directory in a macro variable. I found a couple of > tables where this path stored. I was successful in getting the path > into a macro with a quick application of PROC SQL. However, when I > went to use the macro variable, I discovered there are a lot of > trailing blanks. No problem (right???) I used compress() trim() and > scan() to try to remove these blanks from both within the PROC SQL (in > the select statement) and in a DATA _NULL_ step. However, none of > these worked. Finally, (after talking to SAS tech support) I tried > assigning the variable back to itself and found the trailing blanks > were dropped. Can somebody provide me with a clue about what is going > on and/or provide a reference for me look at that might explain this > behavior. Below is a sample of the code I used to remove blanks and > test to see if they were "trimmed". The "*" is simply a tag to mark > the end of the string contained in the macro. > > proc sql; > select path into :worklib > from sashelp.vslib > where upcase(libname)='WORK'; > quit; > > %put &worklib. '*'; > > data _null_; > work1=compress("&worklib.",' '); > call symput('work1',work1); > run; > > %put &work1. '*'; > > data _null_; > work2=trim("&worklib."); > call symput('work2',work2); > run; > > %put &work2. '*'; > > data _null_; > work3=scan("&worklib.",1,' '); > call symput('work3',work3); > run; > > %put &work3 '*'; > > %let worklib=&worklib.; > %put &worklib. '*'; > > The log ran clean. I am running 6.12 on under SunOS 2.5 on a > Sparc1000. I appreciate any assistence. > > Thank you > > Max Atwood (matwood@ix.netcom.com) >


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