BookmarkSubscribeRSS Feed
Aidan
Quartz | Level 8

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;
7 REPLIES 7
Reeza
Super User

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...

Aidan
Quartz | Level 8

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;

Reeza
Super User

@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. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

Aidan
Quartz | Level 8
Just seeing if its possible
ballardw
Super User

@Aidan wrote:
Just seeing if its possible

Note with proc export. Export is very limited.

Tom
Super User Tom
Super User

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 3430 views
  • 1 like
  • 5 in conversation