BookmarkSubscribeRSS Feed
oujiang
Calcite | Level 5

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?

5 REPLIES 5
JerryLeBreton
Pyrite | Level 9

Use the COMPBL function.


oujiang
Calcite | Level 5

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?

JerryLeBreton
Pyrite | Level 9

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

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


JerryLeBreton
Pyrite | Level 9

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

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


Astounding
PROC Star

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.

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 2694 views
  • 0 likes
  • 3 in conversation