Hello SAS community,
I have a dataset of N=107 and I use
proc export data=Apollo_final
dbms=csv outfile='apollo.csv'
replace;
delimiter = "|";
run;
but 2 of the observations broke from this
into this in the CSV output. Any help?
It is really hard to tell from PHOTOGRAPHS of text what you mean.
Let's assume you mean that the CSV file has more LINES than the number of OBSERVATIONS that existed in the SAS dataset.
There are two issues that will cause the generated CSV file to appear to have more lines. Some of the text values have embedded end-of-line characters in them. The lines being written were too long and so SAS wrapped to the next line to finish writing the observation.
For the second problem make sure that the LRECL used when writing the text file is large enough to hold the longest possible line.
For the first problem you should clean the data and remove (or replace) any CR and/or LF characters in the data. If you tell SAS to write the text file using CR+LF as the end-of-line marker then you can leave in the LF and CR characters as long are they are no CR+LF pairs.
filename csv 'apollo.csv' lrecl=1000000 termstr=crlf;
data for_export;
set apollo_final;
array _char_ _character_;
do over _char_;
_char_ = tranwrd(_char_,'0D0A'x,'0D'x);
end;
run;
proc export data=for_export dbms=csv outfile=csv ;
delimiter = "|";
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.