Write and run SAS programs in your web browser

Proc Export

Reply
Contributor
Posts: 57

Proc Export

Hi There

 

I want to add blank spaces at the end of my exported .csv file.

The csv file is formatted correctly but I cannot get the blank spaces at the end. It stops at 475 but need it to continue to col 600

The data is all concatenated into 1 string and is all converted to text as per attached

 

 

 

PROC EXPORT DATA=work.W4NV5KA
OUTFILE="\\xxxx\xxx\xxxx\Test.txt";
DBMS=CSV REPLACE;
PUTNAMES=NO; 
RUN;
Grand Advisor
Posts: 16,416

Re: Proc Export

It sounds like you need a fixed width format instead? But that wouldn't make sense with a comma delimited file. 

Your best bet is a manual export using a data step you can specify the LRECL to indicate your record length. 

You can start off by using the code generated in the log from your PROC EXPORT and add the LRECL to the FILE statement. 

 

 

http://stats.idre.ucla.edu/sas/faq/how-do-i-write-out-a-file-that-uses-commas-tabs-or-spaces-as-deli...

 

 

File statement docs

http://support.sas.com/documentation/cdl/en/lestmtsref/69738/HTML/default/viewer.htm#n15o12lpyoe4gfn...

Contributor
Posts: 57

Re: Proc Export

[ Edited ]

Do you mean jsut add the LRECL = 650 for example below?

 


PROC EXPORT DATA=work.W4NV5KA
OUTFILE="\\xxxx\Test.txt" LRECL=650
DBMS=TAB REPLACE;
PUTNAMES=NO;
RUN;

Grand Advisor
Posts: 16,416

Re: Proc Export


Aidan wrote:

Do you mean jsut add the LRECL = 650 for example below?

 


PROC EXPORT DATA=work.W4NV5KA
OUTFILE="\\xxxx\Test.txt" LRECL=650
DBMS=TAB REPLACE;
PUTNAMES=NO;
RUN;


LRECL is not a valid option in PROC EXPORT. I'm not seeing a way to do this using PROC EXPORT. The first link has an example of the data step code. You'd change the LRECL in the FILE statement in the data step. 

 

I'm assuming that setting the 'string' to a length of 650 didn't automatically give you a length of 650. 

Esteemed Advisor
Esteemed Advisor
Posts: 6,726

Re: Proc Export

Errm, CSV = Comma Separated Variable file.  What does spaces have to do with this?  The comma is the delimiter.

Contributor
Posts: 57

Re: Proc Export

Just seeing if its possible
Grand Advisor
Posts: 9,748

Re: Proc Export


Aidan wrote:
Just seeing if its possible

Note with proc export. Export is very limited.

Super User
Super User
Posts: 5,990

Re: Proc Export

It is possible. Stupid, but possible.

Use a FILENAME statement so you can tell SAS that your file should be fixed length.

filename csv temp lrecl=30 recfm=f;
proc export data=sashelp.class file=csv replace
  dbms=csv 
;
run;
data _null_;
  infile csv length=len;
  input;
  put _n_ 3. len 3. +1 _infile_;
run;
Post a Question
Discussion Stats
  • 7 replies
  • 73 views
  • 1 like
  • 5 in conversation