Actuarial Outpost
 
Go Back   Actuarial Outpost > Actuarial Discussion Forum > Software & Technology
FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions

United Kingdom
Actuarial Jobs

General Insurance, Life & Other Areas

Canada
Actuarial Jobs

Casualty, Life,
Pension,
Health &
Investment

Entry Level
Actuarial Jobs

All Disciplines
Health, Life, Pension, Casualty, Investment

D.W. Simpson
& Company

Actuarial
Recruiters

Worldwide
www.dwsimpson.com


Reply
 
Thread Tools Display Modes
  #1  
Old 02-18-2009, 04:34 PM
1695814's Avatar
1695814 1695814 is offline
Member
SOA AAA
 
Join Date: Aug 2002
Studying for FSA Financial Reporting
Favorite beer: Root Beer
Posts: 23,068
Default SAS truncate a string

Is there a better way to do this?

I have two string variables, VAR1 $24. & VAR2 $13.;

Sometimes VAR1 = 'HARDY_______________'; /* '_' represents spaces */
But other times VAR1 = 'WONT YOU BE MY NEIGHBOR?';

Additionally, VAR2 = 'HAR HAR______';
But other times VAR1 = 'NOT A CHANCE';

I am concatenating the two vars: VAR3 = VAR1 !! VAR2;
The problem is those spaces at then end of VAR1 when VAR1 = hardy____...

I want VAR3 = 'HARDY HAR HAR';
not 'HARDY_____________ HAR HAR_______';

This is how I tried to get around it: VAR3 = COMPRESS(VAR1 !! VAR2,'__'); /* '__' represents two spaces. */

SAS ignored the two spaces & and compressed ALL spaces so VAR3 = 'HARDYHARHAR';

There's got to be something out there for this.

Maybe a TRIM statement?
__________________
.
[this space for rent]
Reply With Quote
  #2  
Old 02-18-2009, 05:00 PM
1695814's Avatar
1695814 1695814 is offline
Member
SOA AAA
 
Join Date: Aug 2002
Studying for FSA Financial Reporting
Favorite beer: Root Beer
Posts: 23,068
Default

Yes, TRIM worked.

More specifically, VAR3 = TRIM(VAR1) !! '_' !! TRIM(VAR2);
/* '_' represents a space. */
/* I had to add a space in between the two otherwise it turned into 'HARDYHAR HAR'. */
__________________
.
[this space for rent]
Reply With Quote
Reply

Tags
sas, trim

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT -4. The time now is 02:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
*PLEASE NOTE: Posts are not checked for accuracy, and do not
represent the views of the Actuarial Outpost or its sponsors.
Page generated in 0.12346 seconds with 7 queries