Creating a CSV file from ODS and need to remove the first label header record? Is this possible?
ods tagsets.csvnoq file=TAPE rs=none;
proc print data=user.step_two noobs;
run;
ods tagsets.csvnoq close;
Can I start proc print with obs=2? I've tried (FIRSTOBS=2) but that fails. Is there and ODS or PROC PRINT option that suppresses the label header record?
So you want a comma delimited text file that does not have a header row?
Why use ODS at all?
data _null_;
file TAPE dsd;
set user.step_two;
put (_all_) (+0);
run;
Do you mean that not only you don't want "labels", which that code will not use, but you do not want the variable names either?
I think that is going to take a data step.
You might try providing a small example data set and how you expect the result to be in the CSV for that data.
If you do this do NOT paste the csv in main message window as the windows reformat text. Paste the CSV into a text box opened on the forum with the </> icon.
If you insist on using tagsets.csvnoq you will also have to provide that tagset as it is not one of the SAS supplied tagsets and we have no way of knowing what is going on inside.
Hi:
Do you want variable names or do you want just the data? If you switch from PROC PRINT to PROC REPORT, you can generate the data without any headers at all if you use the NOHEADER option as shown below:
Cynthia
So you want a comma delimited text file that does not have a header row?
Why use ODS at all?
data _null_;
file TAPE dsd;
set user.step_two;
put (_all_) (+0);
run;
Thanks Tom, this essential gets me what I need.
What is the (+0) on the PUT statement? It seems to be a column or line pointer from what I'm reading on the PUT statement?
You need to use the (varlist) (fmtlist) syntax of the PUT statement because of the two different meanings of the _ALL_ keyword. With the () the _ALL_ keyword includes all of the variables in the dataset (at least all of them that the compiler has seen already). But without the () the _ALL_ keyword in a PUT statement has a different meaning. It will print all of the variables, including automatic variables like _N_, with their names in front of them.
But for the (varlist) (fmtlist) to work you need something non empty in the FMTLIST. So using +0 to move column zero positions is one option. You could also include a format modifier like : . I used to use the : since it was one less character, but the +0 is a little clearer that it is doing nothing. Plus it won't look like an emoticon. ( 🙂
Tom,
If I now need to add new variables to this data step and order them, how would I exactly do this?
data _null_;
file TAPE dsd;
set user.nfctape;
if size=0 then delete;
if account='' then account='nfcunknown';
if account=. then account='nfcunknown';
size=size*.001**3;
put (_all_) (+0);
The system receiving this file expects to find a identifier/value match on the comma delimited file.
data _null_;
file TAPE dsd;
set user.nfctape;
id='FEEDID';
sysid='SYSTEMID';
acntcd='ACCOUNTCODE';
start='BILLSTARTDATE';
end='BILLENDDATE';
rate='ZRMM0012';
hlq1='DSNACCOUNTCODE1';
put id ident sysid system acntcd account start start_date
end end_date rate size hlq1 hlq;
if size=0 then delete;
if account='' then account='nfcunknown';
if account=. then account='nfcunknown';
size=size*.001**3;
put (_all_) (+0);
run;
Would I just order all the new variables I created along with the variables received from the set command in the put (......) statement?
Yes. You can just list the variables on the PUT statement to control the order they are written. Since you are no longer using the _ALL_ keyword no need to for the ( ) or the (+0).
put id sysid .... ;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.