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
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;
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;
Would compressing out control charters work? compress(var,'','C')?
EJ
Thanks Tom.
Eric, that removes it, but I need a space in that location, otherwise my cities (Red[]Deer) becomes RedDeer.
Gotcha -- didnt think of that.
EJ
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.
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.
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.