BookmarkSubscribeRSS Feed
raveena
Obsidian | Level 7

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.

10 REPLIES 10
art297
Opal | Level 21

PROC EXPORT DATA= WORK.TEST

            OUTFILE= "C:\want.txt"

            DBMS=DLM REPLACE;

     DELIMITER='7E'x;

     PUTNAMES=NO;

RUN;

raveena
Obsidian | Level 7

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;

Tom
Super User Tom
Super User

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.

art297
Opal | Level 21

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.

SASKiwi
PROC Star

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

raveena
Obsidian | Level 7

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.

SASKiwi
PROC Star

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

Tom
Super User Tom
Super User

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

Peter_C
Rhodochrosite | Level 12

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)

art297
Opal | Level 21

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 31431 views
  • 3 likes
  • 5 in conversation