01-09-2017 05:16 AM
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.
create view work.W4NV5KA as
select RecordType||UndertakingID||ContactName||ContactPhone||Email||PUT(Date, yymmddn8.) as Heading
PROC PRINT DATA=work.W4NV5KA;
PROC EXPORT DATA=work.W4NV5KA
PUTNAMES=NO; /* must be set to no to hide the column heading of the variable in the header section of the file.*/
01-09-2017 06:34 AM
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.
01-09-2017 10:04 AM
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.