BookmarkSubscribeRSS Feed
navinrraj
Calcite | Level 5

hi there!

please help me to figure what mistake occur here

balls=compress('12(','(');

i want remove "(" open parenthesis for all variables "balls"

balls is variable name

"12(" is observation value like for entire variable columns

"3)" and so on.

8 REPLIES 8
Patrick
Opal | Level 21

The syntax as such is correct. What's the problem? What's not working?

Please provide representative sample data in the form of a working and tested SAS data step and then explain us how the desired result should look like - or just post the data of the desired outcome.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

And what is the problem?  That code works fine:

data want;
  balls=compress('12(','(');
run;
navinrraj
Calcite | Level 5

but 12 prints entire column

i want print 12 value for paritcular row only

balls=compress('12(','(');

is not working for tat

balls

12

12

12

12

12

12 its print like this

Patrick
Opal | Level 21

@navinrraj

How do you expect us to help you if you don't show us what you have and what you need? Please spend a bit of time to formulate a clear question and provide all the information required to answer your question (...you've got more characters here than on Twitter so don't hold back...)

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Please post a comprehensive example of what you mean.  The statement:

balls=compress('12(','(');

Will, for every row, set the value to be 12 as that is what you have told it to do.  What is it you want?  Maybe:

if findc(balls,"(") then balls=compress(balls,"(");

 

Don't keep  us guessing, test data in the form of a datastep and what you want out!!!

ballardw
Super User

@navinrraj wrote:

but 12 prints entire column

i want print 12 value for paritcular row only

balls=compress('12(','(');

is not working for tat

balls

12

12

12

12

12

12 its print like this


HOW are you "printing"?

"Particular row" how do you identify the "particular row". There is nothing in your (very incomplete) code that restricts this to any specific row.

Astounding
PROC Star

A few simple answers will let any one of the responders on this board solve your problem.  I apologize if they seem too simple.

 

Is your data already in a SAS data set?

 

If so, do you know the names of the variables in the SAS data set?

 

If so, what is the name of the variable that might contain a left-hand parenthesis that you want to remove?

 

Are there any other characters (besides a left-hand parenthesis) that you might want to remove?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 8 replies
  • 1162 views
  • 0 likes
  • 6 in conversation