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
Perhaps you could try to use FILENAME with RECFM=F.
Would you have an example of how I could apply this to the current code?
Thanks
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.
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
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.