- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I will try your suggestion. Many thanks