BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
DPraba79
Calcite | Level 5
Insted of compress function. Use TRIM function, then you will get desire output
venkatesh
Calcite | Level 5
Try this

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


Cheers,
Venky.
DanielSantos
Barite | Level 11
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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1168 views
  • 0 likes
  • 5 in conversation