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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.