STRIP FUNCTION

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

STRIP FUNCTION


This is also similar to the question I asked earlier on arrays.

I have variables DX1-DX30 . They contain value of 1, 0 or nothing....its a character variable.

some of the values have spaces before them...

How can I perform the strip function to all the variables efficiently???

Thanks


Accepted Solutions
Solution
‎10-24-2014 09:47 AM
Trusted Advisor
Posts: 1,203

Re: STRIP FUNCTION

data want;

set have;

array DX(*) DX1-DX30;

do i=1 to dim(dx);

dx{i}=strip(dx{i});

end;

run;

View solution in original post


All Replies
Solution
‎10-24-2014 09:47 AM
Trusted Advisor
Posts: 1,203

Re: STRIP FUNCTION

data want;

set have;

array DX(*) DX1-DX30;

do i=1 to dim(dx);

dx{i}=strip(dx{i});

end;

run;

Super Contributor
Posts: 1,040

Re: STRIP FUNCTION

Okie.....sounds great

here we are stripping the same variable and updating the information......

is that what it means????

I was thinking earlier to my post that I cannot do other than creating a new 30 varibles(exSmiley Very HappyXX1-DXX30) .stripping and renaming them to DX1-DX30...

This is very nice information you shared!!!

Regards

Trusted Advisor
Posts: 1,203

Re: STRIP FUNCTION

Hi,

Yes, we can update variables in this way without creating new ones.

Regards

Super User
Super User
Posts: 6,323

Re: STRIP FUNCTION

It is faster to type the code if you just use the DO OVER loop instead.  For these types of arrays where the index is meaningless I find that DO OVER syntax is more appropriate in addition to requiring less typing.

data want;

  set have;

  array DX DX1-DX30;

  do over dx;

    dx=strip(dx);

  end;

run;



☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 245 views
  • 4 likes
  • 3 in conversation