## STRIP FUNCTION

Solved
Super Contributor
Posts: 1,041

# 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
Posts: 1,270

## Re: STRIP FUNCTION

Posted in reply to robertrao

data want;

set have;

array DX(*) DX1-DX30;

do i=1 to dim(dx);

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

end;

run;

All Replies
Solution
‎10-24-2014 09:47 AM
Posts: 1,270

## Re: STRIP FUNCTION

Posted in reply to robertrao

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,041

## 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(exXX1-DXX30) .stripping and renaming them to DX1-DX30...

This is very nice information you shared!!!

Regards

Posts: 1,270

## Re: STRIP FUNCTION

Posted in reply to robertrao

Hi,

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

Regards

Super User
Posts: 8,081

## Re: STRIP FUNCTION

Posted in reply to robertrao

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 and locked.

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

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