|
Experiment using the similar logic as you have used, but use the
macro versions of compress and trim.
On Mon, 3 Mar 1997 18:24:32 -0600, Ronald Max Atwood Jr
<matwood@IX.NETCOM.COM> wrote:
>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)
======================================================================
Advanced Data Analysis, Est.'89. Over 19 years experience with general
statistical consulting and multi-platform SAS programming. Also: data
conversions across platforms, media, and applications. Data storehouse
and conversion for '90 census, health, nutrition, and other government
databases. //www.his.com/rltstats, rob.thomas@his.com, 301-949-8065
======================================================================
|