I am using below proc export to generate a text file with delimiter, § (section sign ALT + 0167) . it perfectly works in Windows but not in Linux. In Linux the generated text file has expected delimiter in only Header but delimiter is changing within data. how to solve this issue?
proc export data=sample
outfile=/user/home/results.txt dbms=dlm
replace;
delimiter="§";
run;
Not a photograph. The actual FILE.
You can use the LIST statement.
data _null_;
infile csv;
input;
list;
run;
Or if you have to the $HEX format to see what characters are in the file.
data _null_;
infile csv;
input;
put _infile_ $hex52.;
run;
Note that using some character that is not a plain old 7-bit ASCII code is going to cause you to have to worry about what ENCODING your SAS session is using and what ENCODING the tool you are using to look at the result is using.
Also when using some non-ASCII character it is usually best if you use the actual HEX CODE instead of pasting the non-standard character into your code so that it is portable and does not get transcoded when you move the code to another environment.
When I use 'A7'X (since I am using LATIN1 encoding) it works fine for me.
data test;
set sashelp.class(obs=2);
run;
filename csv temp;
proc export data=test file=csv replace dbms=csv;
delimiter='A7'x;
run;
Result
244 data _null_; 245 infile csv; 246 input; 247 put _infile_ $hex52.; 248 run; NOTE: The infile CSV is: (system-specific pathname), (system-specific file attributes) 4E616D65A7536578A7416765A7486569676874A7576569676874 416C66726564A74DA73134A73639A73131322E35 416C696365A746A73133A735362E35A73834 NOTE: 3 records were read from the infile (system-specific pathname). The minimum record length was 18. The maximum record length was 26. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 249 data _null_; 250 infile csv; 251 input; 252 list; 253 run; NOTE: The infile CSV is: (system-specific pathname), (system-specific file attributes) RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 Name§Sex§Age§Height§Weight 26 2 Alfred§M§14§69§112.5 20 3 Alice§F§13§56.5§84 18 NOTE: 3 records were read from the infile (system-specific pathname). The minimum record length was 18. The maximum record length was 26. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
What does the delimiter change to in Linux?
Best might be to post 5 or 10 lines of the resulting exported file. Copy the the lines and then paste into a text box opened on the forum with the </> icon that appears above the message window.
If the data is at all sensitive use a SAS supplied data set like SASHELP.CLASS as the data= dataset.
@ballardw I've uploaded screenshot of txt file. the header has the delimiter (§) as expected but delimiter changed within data.
Not a photograph. The actual FILE.
You can use the LIST statement.
data _null_;
infile csv;
input;
list;
run;
Or if you have to the $HEX format to see what characters are in the file.
data _null_;
infile csv;
input;
put _infile_ $hex52.;
run;
Note that using some character that is not a plain old 7-bit ASCII code is going to cause you to have to worry about what ENCODING your SAS session is using and what ENCODING the tool you are using to look at the result is using.
Also when using some non-ASCII character it is usually best if you use the actual HEX CODE instead of pasting the non-standard character into your code so that it is portable and does not get transcoded when you move the code to another environment.
When I use 'A7'X (since I am using LATIN1 encoding) it works fine for me.
data test;
set sashelp.class(obs=2);
run;
filename csv temp;
proc export data=test file=csv replace dbms=csv;
delimiter='A7'x;
run;
Result
244 data _null_; 245 infile csv; 246 input; 247 put _infile_ $hex52.; 248 run; NOTE: The infile CSV is: (system-specific pathname), (system-specific file attributes) 4E616D65A7536578A7416765A7486569676874A7576569676874 416C66726564A74DA73134A73639A73131322E35 416C696365A746A73133A735362E35A73834 NOTE: 3 records were read from the infile (system-specific pathname). The minimum record length was 18. The maximum record length was 26. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 249 data _null_; 250 infile csv; 251 input; 252 list; 253 run; NOTE: The infile CSV is: (system-specific pathname), (system-specific file attributes) RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 Name§Sex§Age§Height§Weight 26 2 Alfred§M§14§69§112.5 20 3 Alice§F§13§56.5§84 18 NOTE: 3 records were read from the infile (system-specific pathname). The minimum record length was 18. The maximum record length was 26. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for 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.