hi,
I am exporting one csv file with text extension.
exmple:
proc export data=prog dbms=csv label outfile="1.txt" replace;
run;
but, I am getting variables and values with double quotes. Can we remove these double quotes?
I have also tried one way
filename file_1 "/location/12.txt";
data _null_;
set program;
file file_1 dlm=',';
put 'var1,var2,var3'
#2 (_all_)(:);
run;
but in this case, when i am opening the file, it is appearing in one line in notepad. i want the file top be show variables in first line and values in second line. can you please provide some guidance?
I have also used ods csv file="//location/1.txt";
ods csv options(sheet_name="tes" flow='tables");
proc print data=programnoobs;
run;
ods csv close;
But again, variable and values are appearing with double quotation.
I need the output in below format. first line variable and second line values.
example:
var1,var2,var3
111,aaa,vvv
Please try the below code
proc export data=prog269_ctrl2 dbms=tab label outfile="1.txt" replace;
putnames=yes;
run;
thanks for your reply. It will not resolve the double quotes. I need the file to be have comma separated value and variables
I need the output in this format first line variables and second line values. example:
var1,var2,var3
111,aaa,vvv
proc export data=prog269_ctrl2 dbms=dlm label outfile="1.txt" replace;
delimiter=',';
putnames=yes;
run;
We can try the delimiter as above
I want the variables to be shown as label values. but it is showing the variables labels in double quotes. how can i remove it?
We need to mention the putnames=no;
proc export data=prog269_ctrl2 dbms=dlm label outfile="1.txt" replace;delimiter=',';
putnames=no;
run;
i am getting this message after using putname=no;
WARNING: The LABEL option will be ignored when PUTNAMES=NO.
also, it is creating file without variable names but i need the variable names.
This should work
proc export data=prog269_ctrl2 dbms=dlm outfile="1.txt" replace;
delimiter=',';
run;
Hi,
i have used below code:
filename file_1 "location/1.txt;
data _null_;
set prior_ds;
file file_1 dlm=',';
put 'Source,val1,val2'
#2 (_all_)(:);
run;
it is writing the variable name i.e source,val1,val2 and the values to the same line .
can you please suggest how i can put values to second line.
Use the code window - its the {i} above post area to post code:
filename file_1 "location/1.txt; data _null_; set prior_ds; file file_1 dlm=','; if _n_=1 then put 'Source,val1,val2'; put (_all_); run;
put (_all_) is erroring out. If i am using _all_ then it is giving results as var1=111 .
But again, the value and variables are showing in the same line in notepad.
but I need the values and variables in separate lines.
@deepakkailay wrote:
put (_all_) is erroring out. If i am using _all_ then it is giving results as var1=111 .
But again, the value and variables are showing in the same line in notepad.
but I need the values and variables in separate lines.
DO NOT use notepad for the display of such datafiles. Windows notepad can't handle non-Windows text files properly.
Use notepad++ instead.
UNIX uses a single LF character for line breaks, while notepad expects the Windows-typical CRLF combo.
Text files from SAS UE will be in UNIX format, unless you specify a termstr=CRLF option in the file statement.
A CSV file will have double quotes in if the data contains the delimiter, consider:
Somevar,Somethingelse,A line with a comma, in,something else
If that is read in the "A line with a comma, in" actually looks like two variables as the comma delimiter appears in the string. To counteract this, SAS (and all other implementations such as Excel) will quote that string to look:
Somevar,Somethingelse,"A line with a comma, in",something else
So it is clear that the comma there is part of a text string not a delimiter. This is standard behaviour, and if your data contains the delimiter, then that should be how it is presented.
thanks,
but i need the output in this way:
first line variable list and second line value with comma separated. Is there a way to get this output?
example:
var1,var2,var3
111,aaa,vvv
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.