The SAS Output Delivery System and reporting techniques

tab delimited file without column header/names

Reply
Occasional Contributor
Posts: 16

tab delimited file without column header/names

I have a dataset with sixty columns and 300 observations.I would like to create a tab delimited file with out the column variables in the first row.
I used below code.But its creating a tab space at the beginning of the first column.Please suggest me a way to create a tab delimited without the variable names in the first row.

data _null_;
file "&fileloc/&outfile" lrecl=32760;
set work.report;
put (_all_)('09'x);
run;

Thanks in advance.
Super Contributor
Super Contributor
Posts: 3,174

Re: tab delimited file without column header/names

Investigate the DLM= keyword (and also DSD) on the FILE for changing this behavior.

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 29

Re: tab delimited file without column header/names

Try adding
DLM='09'x DSD
to your file statement

change your put statement to
put (_all_) ($);
Occasional Contributor
Posts: 16

Re: tab delimited file without column header/names

Thanks Gary.It worked.
It would be very helpful if you can give a brief explanation of how $ symbol next to put statement fixed this issue.

Thanks in advance.
Contributor
Posts: 29

Re: tab delimited file without column header/names

I was experimenting based on this post I found in the knowledge base http://support.sas.com/kb/24/843.html
and got an error message that SAS was expecting a quoted string, $, &, /, //, :, =, ?, ~ (I think that's everything.)
When I tried the $, I got the result I wanted. I tried the others too and some gave me the same results as the $ while others like / inserted a carriage return. I'm not sure exactly what's going on, but it works, so I decided to post it.
SAS Super FREQ
Posts: 8,743

Re: tab delimited file without column header/names

Hi:
Some comments...when you use PUT (_ALL_) you are tellling SAS to write ALL of the variables from the PDV (Program Data Vector) to the output file specified on the FILE statement. When you use a PUT like this, what you can (and should) always specify is the format to use to write the variables. The ($) tells SAS to use a character format for EVERYTHING that's being written.

In addition, the DLM= option and the DSD options on the FILE statement tell SAS to use the tab character (09'x) as the separator/delimiter and the DSD option tells SAS to put quotes around variable values which contain spaces and special characters, as described here:
http://support.sas.com/documentation/cdl/en/lrdict/63026/HTML/default/viewer.htm#a000171874.htm

So in your case, the original PUT statement was never going to work:
[pre]
put (_all_)('09'x);
[/pre]

because ('09'x) is NOT a format -- it is what you wanted to use as a delimiter and it needed to be specified in the DLM= option. With just PUT (_ALL_) and NO format list, you would have gotten this error:
[pre]
1658 put (_all_);
-
79
76
ERROR 79-322: Expecting a (.

ERROR 76-322: Syntax error, statement will be ignored.

[/pre]


So the ($) made the PUT statement happy with a format to use for every variable in the PDV. And the DLM= option told SAS to use the tab as the separator.

cynthia
Occasional Contributor
Posts: 16

Re: tab delimited file without column header/names

Thanks for the explanation Cynthia and Gary.
Ask a Question
Discussion stats
  • 6 replies
  • 871 views
  • 0 likes
  • 4 in conversation