The SAS Output Delivery System and reporting techniques

delete blank

Reply
Occasional Contributor
Posts: 9

delete blank

hi!

i have a word like this "At        63.6%       , the labour-force participation rate is at its lowest level",

but I want to get the result like this "At 63.6%, the labour-force participation rate is at its lowest level",

What should I do?

Frequent Contributor
Posts: 85

Re: delete blank

Use the COMPBL function.


Occasional Contributor
Posts: 9

Re: delete blank

not work,have a error !

ERROR: The function COMPBL referenced by the %SYSFUNC or %QSYSFUNC macro function has too many  arguments.

Will not be the "%" problem?

Frequent Contributor
Posts: 85

Re: delete blank

If your are doing this in a macro, you will need something like this:

%let want = %sysfunc(tranwrd(%qsysfunc(compbl(%quote(&have))), %str(% ,), %str(%,)));


Frequent Contributor
Posts: 85

Re: delete blank

Ah yes, then to get rid of the space between % and ,

     tranwrd(compbl(string),  " ,",  ",")


Respected Advisor
Posts: 4,648

Re: delete blank

It would be easier to correct the problem earlier in the process, rather than after the string has been created.

Your code has created a macro variable that contains leading and trailing blanks, such as       63.6%

Get rid of the leading and trailing blanks before plugging that into the longer string.  One easy way:

%let macrovar = &macrovar;

Then plug it in:

%let string = At &macrovar, the labour-force participation rate is at its lowest level;

Good luck.

Post a Question
Discussion Stats
  • 5 replies
  • 449 views
  • 0 likes
  • 3 in conversation