Help using Base SAS procedures

concatenate

Reply
N/A
Posts: 0

concatenate

mt = 050;
PP = '20+';
U='>90';


xxx=compress(mt||'DAYS '||PP||U);

I'm getting xxx value as '050DAYS20+>90'

I want it '050DAYS 20+>90' A space after "DAYS"

what should i do?
Super Contributor
Super Contributor
Posts: 3,174

Re: concatenate

You are using the COMPRESS function, yet you don't want to compress? Consider using one of the SAS-supplied CAT-related functions, instead.

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 34

Re: concatenate

Insted of compress function. Use TRIM function, then you will get desire output
Contributor
Posts: 61

Re: concatenate

Try this

xxx=compress(mt||'DAYS'||' '||PP||U);


Cheers,
Venky.
Super Contributor
Posts: 474

Re: concatenate

You're having trouble to understand how compress works.

Compress, by default will remove blank chars from its argument, or any other char you may specify as a second argument.

Please READ the help doc here: http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000212246.htm

(venkatesh this goes for you also, unless you misunderstood the problem)

Now, there is a multitude of functions and operators that will accomplish what you need.

For example:
[pre]
xxx=strip(MT)!!'DAYS '!!strip(PP)!!strip(U);
xxx=cats(MT,catx(' ','DAYS',PP),U);
xxx=strip(MT)!!'DAYS '!!cats(PP,U);
xxx=trim(left(MT))!!'DAYS '!!trim(left(PP))!!trim(left(U));
...
[/pre]
Please spend some time reading the documentation of this string manipulation functions:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000212224.htm
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000212226.htm
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a002295689.htm
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a002256540.htm
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a002257076.htm

Cheers from Portugal.

Daniel Santos @ www.cgd.pt
Ask a Question
Discussion stats
  • 4 replies
  • 152 views
  • 0 likes
  • 5 in conversation