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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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