Date: Tue, 21 Jul 2009 12:29:08 -0400
Reply-To: Søren Lassen <s.lassen@POST.TELE.DK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Søren Lassen <s.lassen@POST.TELE.DK>
Subject: Re: Eliminating Trailing Spaces
Content-Type: text/plain; charset=ISO-8859-1
Your range should come out OK using CATX:
range1 = catx(' ',minvent,'-',maxvent);
- but then I think the more complicated code you have written
also works OK - if I understand you correctly, the problem is trailing
blanks in Excel, not the range itself. I see that you are using
the @char. format to put the range into another variable, are you also
using that format to write to Excel? That may explain the trailing
blanks. If you can't get rid of the trailing blanks by dropping the
format on the PUT statement, you can try the $varying. format:
put range $varying. len;
On Tue, 21 Jul 2009 10:19:28 -0500, Herbert Morley A
>OK SAS Gurus- what I am I missing?
>I am analyzing data from cardiac surgery and then writing the results into
an Excel template using DDE. There are hundreds of fields and 20+
spreadsheets to populate. Works like a charm, having been revised each year.
>I have one problem and have been unable to make it work.
>Using Proc Means, I output the minimum and maximum values of the vent time
variable to create a range. What I want is something that looks like
>6.3 - 289.4 . I accomplish this by concatenating the values.
>Using this code I get what I want with the exception of the trailing
blanks that I can't seem to figure out how to trim off. Ideally I would
like to measure the length of range1 and just set the length of range2 to
that. Unfortunately (after all it is medical data) the length of the
minvent variable could go from 1 digit to maybe 4 while the maxvent goes to
maybe 6 digits. That combined with the dashes and spaces around it mean the
range2 length may vary from 6 to maybe 13 characters. The only reason that
the trailing spaces are an issue is that I want it centered in the cell in
Excel and with the spaces padding range2, it is offset. I can go in by hand
and delete the trailing spaces but that is a 'pain'.
> SET totcnt;
>range1 = STRIP(COMPBL(minvent||" - "||TRIM(LEFT(maxvent))));
>range2 = PUT(range1, $char14.);
>I have tried things like
> range = TRIM(LEFT(range2));
>I have also tried finding the first trailing space and then using substr
fiunction to only read up to there. It says that it has only read the
appropriate number of characters, but when I transfer it to Excel, the
spaces are back.
>Someone must know how to get rid of the spaces.
>I thank you for any help offered.