BookmarkSubscribeRSS Feed
fadtt
Calcite | Level 5

Hi everyone,

please I need assistance to resolve an issue. The issue is on how to use macro to remove parenthesis () from variable string. For example given the following variables:

(cup table plates iron street home) but I need the remove the () in order to work with the variables.

Thanks.

3 REPLIES 3
art297
Opal | Level 21

You can get rid of them by using the compress function.  e.g.:

data have;

  informat stuff $80.;

  input stuff &;

  have=compress(stuff,"()");

  cards;

(cup table plates iron street home)

;

fadtt
Calcite | Level 5

Thanks art297 I know that is possible but I like to solve this using macro function.

Reeza
Super User

To clarify are you looking to USE a macro function or to create a macro to do this.

If you want to create a macro what do you envision as the input and what as the output?

Some of the macro functions you'll can look into are:

%scan

%if %then %do

Or you could just wap the compress function in a macro .

You could always use a find or index function in a data _null_ step.

Basically there's many ways to do this and it sounds a lot like a home work question to me.

You should also move this thread to the macro language forum.

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!

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