BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.

I've imported an Excel file, which appears to have imported correctly.

However fields that have the Alt+Enter have a box [] in them, and I'd like to replace it with a space instead.

The compress function with "CH" parameters removes them, but I need a space instead.

The solutions I've found indicate saving as CSV instead, but I'd like to modify the data rather than re-import.

I thought about the translate and tranwrd function, but couldn't figure out how to specify my space. I think its "A0"x but not sure how to verify that either.

TIA,

Reeza

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Most likely the character is '0A'x, which is a linefeed.

data want ;

   set have ;

   array _c _character_ ;

   do over _c;

    _c = translate(_c,' ','0A'x) ;

  end;

run;

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

Most likely the character is '0A'x, which is a linefeed.

data want ;

   set have ;

   array _c _character_ ;

   do over _c;

    _c = translate(_c,' ','0A'x) ;

  end;

run;

esjackso
Quartz | Level 8

Would compressing out control charters work? compress(var,'','C')?

EJ

Reeza
Super User

Thanks Tom.

Eric, that removes it, but I need a space in that location, otherwise my cities (Red[]Deer) becomes RedDeer.

esjackso
Quartz | Level 8

Gotcha -- didnt think of that.

EJ

snoopy369
Barite | Level 11

Would be nice if COMPRESS had an option to replace-with-space instead of remove - of course that's what TRANSLATE does, but writing it as

x=compress(x,,'cz'); *where z=replace with space;

would be easier than the translate code when dealing with longer lists of things.

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
  • 3440 views
  • 0 likes
  • 4 in conversation