This is the first few rows of my data
0002 | C | 00001 | IV | R1 | 2 | 025VS | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | C | 00001 | IV | R3 | 2 | 053VS | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | C | 00001 | LG | R1 | 2 | 5408V | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | B | 00001 | UB | DS | 2 | 126PD | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | C | 00001 | UB | DS | 2 | 126PD | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | B | 00001 | UB | DS | 2 | 465PD | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | C | 00001 | UB | DS | 2 | 465PD | 1111111 | 1 | 1 | 12 | 0 | . | C | |||
0002 | C | 00001 | UB | DS | 2 | 670PD | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | B | 00001 | UB | DS | 2 | 678PD | 1111111 | 1 | 1 | 1 | 0 | . | C | |||
0002 | C | 00001 | UB | DS | 2 | 678PD | 1111111 | 1 | 1 | 3 | 0 | . | C | |||
0002 | B | 00001 | UB | DS | 2 | G5012 | 1111111 | 1 | 1 | 6 | 0 | . | C |
This is my code for the export
proc export data = class.merged_n /*Export merged_n as a csv*/
outfile = 'C:\...\merged_n.csv'
dbms = csv
replace;
run;
This is the output, from notepad. Opening in excel it says "File not loaded completely"
0002,C,00001,IV,R1,2,025VS,1111111
1,1,,,,0,,C
0002,C,00001,IV,R3,2,053VS,1111111
1,1,,,,0,,C
0002,C,00001,LG,R1,2,5408V,1111111
1,1,,,,0,,C
0002,B,00001,UB,DS,2,126PD,1111111
1,1,,,,0,,C
0002,C,00001,UB,DS,2,126PD,1111111
1,1,,,,0,,C
0002,B,00001,UB,DS,2,465PD,1111111
1,1,,,,0,,C
0002,C,00001,UB,DS,2,465PD,1111111
1,12,,,,0,,C
0002,C,00001,UB,DS,2,670PD,1111111
1,1,,,,0,,C
0002,B,00001,UB,DS,2,678PD,1111111
1,1,,,,0,,C
0002,C,00001,UB,DS,2,678PD,1111111
1,3,,,,0,,C
0002,B,00001,UB,DS,2,G5012,1111111
1,6,,,,0,,C
0002,C,00001,UB,DS,2,G5012,1111111
1,45,,,,0,,C
You can see the unexpected carriage returns. How to remedy this?
Thanks in advance
PROC EXPORT is not going to insert any extra line breaks. If there are LineFeeds ('0A'x) or CarrriageReturns ('0D'x) in the output then they are in the input.
Are you sure the data you posted are the same? The first appears to have more variables than the second. In particular look at the first observation of each. Notice how there are three cells in a row with '1' in them in the table you posted. But in the text you posted the first two lines have only one cell with '1' in it.
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 25. 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.