BookmarkSubscribeRSS Feed
Aidan
Quartz | Level 8

Hi there,

 

I am generating an output file with a heading. There are numerous columns concateneated together below. After these I need to add blank spacing of 40 characters so the file will upload in a set format to external area.

 

Any ideas on how I can manipulate the current file as SAS seems to remove blanks on export.

 

 

proc sql;
create view work.W4NV5KA as
select RecordType||UndertakingID||ContactName||ContactPhone||Email||PUT(Date, yymmddn8.) as Heading
from &SYSLAST
;
quit;

PROC PRINT DATA=work.W4NV5KA;
RUN;

PROC EXPORT DATA=work.W4NV5KA
OUTFILE="C:\test.txt"
DBMS=TAB REPLACE;
PUTNAMES=NO; /* must be set to no to hide the column heading of the variable in the header section of the file.*/
RUN;
PROC PRINT;
RUN;

 

 

Thanks,

Aidan 

 

5 REPLIES 5
LinusH
Tourmaline | Level 20

Perhaps you could try to use FILENAME with RECFM=F.

Data never sleeps
Aidan
Quartz | Level 8

Would you have an example of how I could apply this to the current code?

 

Thanks

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry, its not clear to me what:

"these I need to add blank spacing of 40 characters so the file will upload in a set format to external area."

 

This means?  Most programs read string in until a certain delimiter, then it doens't matter what length things are.  What exactly is it your trying to do, and if your coming up with your own file format structure, why does one of the standardly adopted file formats (such as CSV, XML etc.) not support your requirements?  Far simpler to use something already standard.

Aidan
Quartz | Level 8

Hi there

 

It has to be a text file to meet requirements so I need to stick with that I have to date

Thanks

Aidan

ballardw
Super User

Instead of "add 40 spaces" think "set the fixed length of the output line"; That is the comibination LRECL= and RECFM=F with the FILE statement. Use the LRECL option to set the output line length. Coupled with the RECFM=F (fixed record format) then every line of the output file will be the length you specify. If there is nothing actually put in those columns at the end then the record is padded with blanks to make it the desired length.

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!

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.

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
  • 5 replies
  • 1708 views
  • 0 likes
  • 4 in conversation