Help using Base SAS procedures

Export data to dat file without header record

Reply
Frequent Contributor
Posts: 90

Export data to dat file without header record

Hi,

I need to export (using proc export) a data to flat file (with tilde delimiter ~ ) without header record in the output.

data test;

input name $ city $ state $;

cards;

Tim orlando Florida

John jersey newjersey

Bob newyork newyork

;

run;

output should be :

Tim~orlando~Florida

John~jersey~newjersey

bob~newyork~newyork

Please let me know

Thanks.

PROC Star
Posts: 7,492

Export data to dat file without header record

PROC EXPORT DATA= WORK.TEST

            OUTFILE= "C:\want.txt"

            DBMS=DLM REPLACE;

     DELIMITER='7E'x;

     PUTNAMES=NO;

RUN;

Frequent Contributor
Posts: 90

Export data to dat file without header record

Hi Art,

I am getting an error as below,

PROC EXPORT DATA= WORK.TEST

83 OUTFILE= "&drv2.\RGA14001\current\dd.dat"

84 DBMS=DLM REPLACE;

NOTE: The previous statement has been deleted.

85 DELIMITER='~';

86 PUTNAMES=NO;

--------

180

ERROR 180-322: Statement is not valid or it is used out of proper order.

87 RUN;

Super User
Super User
Posts: 7,077

Export data to dat file without header record

You just got some extra characters into your program. The error message is that it did not understand the PROC statement.  So of course it does not understand the other statements that only apply when running PROC EXPORT.

PROC Star
Posts: 7,492

Export data to dat file without header record

You would have to post the code you actually submitted, including the line that assigns the macro variable, in order for anyone to figure out what the problem is.  You may also have tried to run the code when something else was already running.

I would save the program, restart SAS, and then see if it works. The program itself appears to be correct.

Super User
Posts: 3,260

Export data to dat file without header record

The PUTNAMES = NO statement is only valid in SAS 9.2 onwards - what version are you using?

Frequent Contributor
Posts: 90

Export data to dat file without header record

Hi kiwi,

I am using SAS 9.1 ...Finally i have applied this logic to get the output without header records,

data null;

File "&drv14.\test" dsd dlm='~' lrecl=32767;

Set  output ;

Put ( _all_)(+0);

run;

Thanks for all your responses.

Super User
Posts: 3,260

Export data to dat file without header record

Here is my solution to the same problem using PROC EXPORT and then using a DATA step after. There are so many ways of solving the same problem in SAS!

http://communities.sas.com/message/105760#105760

Super User
Super User
Posts: 7,077

Export data to dat file without header record

I am not sure why people use PROC EXPORT to create text files. The data step is in many ways easier and more flexible.

Valued Guide
Posts: 2,177

Export data to dat file without header record

Tom wrote:

I am not sure why people use PROC EXPORT to create text files. The data step is in many ways easier and more flexible.


not to mention - simpler, more reliable and probably producing more dense files (only quoting when neccessary)

PROC Star
Posts: 7,492

Export data to dat file without header record

Tom,

Many of us use procs import and export because we figure that SAS would have made the task easier and with more capabilties than we could have accomplished on our own.  Unfortunately, that isn't always the case as we have discovered with procs import and export.

Hey, we could also accomplish building a neural net, logistic regression, or what have you in a datastep as well but, I think, most of us would simply use the procs included with Enterprise Miner and SAS/STAT.

Me thinks that your comment should be taken as a wake up call to those who are responsible for procs import and export.  Some of our colleagues and I are doing a presentation at SGF2012 related to proc import, specifically about importing tables that one might copy from the web.  We, too, had to build code in a datastep because proc import didn't provide the necessary capabilities.  Obviously, a much better job could have been done if we had access to the actual source code.

Ask a Question
Discussion stats
  • 10 replies
  • 15192 views
  • 2 likes
  • 5 in conversation