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 (July 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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

Herbert, 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: len=length(range); put range $varying. len;

Regards, Søren

On Tue, 21 Jul 2009 10:19:28 -0500, Herbert Morley A <Morley.Herbert@HCAHEALTHCARE.COM> wrote:

>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'. >DATA _NULL_; > 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. >Sincerely >Morley Herbert


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