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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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