I'm trying to export some data to a fixed width text file. I can export the data okay. The problem is that the customer wants the last column (Filler) to be 42 characters. When I look at the file in a hex editor I only see 2 spaces at column 121. How can I add those extra spaces? Also how do I add column names if I want to?
Thanks
data _null_;
set final end=last;
file "&&loc_&server_dest./&TextOut." LRECL=162 TERMSTR=crlf recfm=v;
put
@1 submitter_id
@11 ssn
@22 incentive_met_date
@30 incentive_code
@40 incentive_amount
@50 ssn_of_the_qualifier
@61 birth_date_of_qualifier
@69 first_name_of_qualifier
@94 last_name_of_qualifier
@119 relationship_code_of_qualifier
@121 Filler
;
run;
data have;
input @1 submitter_id $6.
@8 ssn $9.
@18 incentive_met_date $8.
@27 incentive_code $4.
/* @40 incentive_amount $10.*/
/* @50 ssn_of_the_qualifier $11.*/
/* @61 birth_date_of_qualifier $8.*/
/* @69 first_name_of_qualifier $25.*/
/* @94 last_name_of_qualifier $25.*/
@32 relationship_code_of_qualifier $2.
;
datalines;
UHCCOE 199997187 20210119 BACK M
UHCCOE 252599991 20210118 BACK M
UHCCOE 289990538 20210125 BACK S
;
RUN;
I'
You have recfm=v which apparently eliminates trailing blanks in filler. But changing to recfm=f will apparently drop the CRLF at the end of each line (just did a test on my windows machine).
Change the end of your PUT statement from
@121 Filler
to
@121 Filler $42.
Doing that caused my sas log to report maximum length and minimum length of output records both at 162, even with a total blank FILLER.
You have recfm=v which apparently eliminates trailing blanks in filler. But changing to recfm=f will apparently drop the CRLF at the end of each line (just did a test on my windows machine).
Change the end of your PUT statement from
@121 Filler
to
@121 Filler $42.
Doing that caused my sas log to report maximum length and minimum length of output records both at 162, even with a total blank FILLER.
@mkeintz wrote:
You have recfm=v which apparently eliminates trailing blanks in filler. But changing to recfm=f will apparently drop the CRLF at the end of each line (just did a test on my windows machine).
Change the end of your PUT statement from
@121 Filler
to
@121 Filler $42.
Doing that caused my sas log to report maximum length and minimum length of output records both at 162, even with a total blank FILLER.
It worked. Do you know how to add column headings? Thanks so much.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.