How do I maintain the spaces when exporting to text?
Ah so you have 3 columns, need 173 length overall and need to maintain embedded spaces within the 3 columns.
So a small change to the example in reply 6 gives you:
data test;
format col1-col3 $char20.;
col1 = "no spaces";
col2 = "no spaces";
col3 = "no spaces";
output;
col1 = " 2 spaces";
col2 = " 3 spaces";
col3 = " 4 spaces";
output;
run;
filename zout 'c:\testText.txt';
data _null_;
set test;
file zout;
pos1 = 5 + (verify(col1,' ') - 1);
pos2 = 50 + (verify(col2,' ') - 1);
pos3 = 100 + (verify(col3,' ') - 1);
put @pos1 col1 @pos2 col2 @pos3 col3 @173 ' ';
run;
filename zout;
I don't think you need to do all that measuring to get @ column. $CHAR format will preserve leading blanks.
Hi Tom
There seems to be a space or 2 after the last character. How can I remove it or ensure that the 173 length ends at the last character.
Hi
Not to worry, I sorted it!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.