Keep leading spaces and blank records

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Keep leading spaces and blank records

I read paper 217-2007 SAS character functions by Ronald Cody and checked the 9.2 reference manual with no luck.

I am reading an 80 byte file in MVS and writing it back out and modifying certain records. I want to retain the leading spaces and blank lines in my output file. It looks like SAS is dropping the blank lines and the output is truncated to the left. I tried using a format of

FORMAT WHOLE1  $CHAR80.;

output =

------- report heading 1 -------

Jobs Report

Job1

Job2

------- report heading 2 -------

jobx

joby

Any recommendations?

Sample of records;

datalines:

1 -------- report heading 1 -------

2

3           Jobs Report

4

5           Job1

6          Job2

7

8 ------- report heading 2 -------

9         

10          jobx

11          joby


Accepted Solutions
Solution
‎07-09-2014 04:35 PM
Respected Advisor
Posts: 3,799

Re: Keep leading spaces and blank records

You need to use $CHAR as your INFORMAT.  Plus you cannot use LIST input but you don't mention that.

Change this INPUT WHOLE1  1-80;

to

input @1 whole1 $char80.;

You need to more the column pointer back to column 1.  You could also do it the read of type

change INPUT @2  TYPE @;

to

input @2 type @1 @;

This input might FLOWOVER so I would add an informat or column range

input @2 type $3. @1 @;

you can also add TRUNCOVER to infile statement to achieve similar effect.

Message was edited by: data _null_

View solution in original post


All Replies
Super User
Posts: 11,343

Re: Keep leading spaces and blank records

Default for most procedures is to drop leading spaces as most of us usually don't want them for row headers and such.

Also an all blank value often gets treated as missing so procedures usually don't show them unless you ask for missing.

You don't say how you are generating your report and/ or the destination such html, listing, pdf, rtf. If you

Some example of the code used to generate the report including destination will help us provide suggestions.


Contributor
Posts: 23

Re: Keep leading spaces and blank records

I am reading in a file and writing it back out - mvs lrecl=80 input, lrecl=80 output:

OPTIONS NOSOURCE MISSING = 0;

DATA _NULL_;

ATTRIB PART1   LENGTH=$24;

ATTRIB TRIGJOB LENGTH=$8;

ATTRIB TYPE    LENGTH=$3;

FORMAT WHOLE1  $CHAR80.;

INFILE INFILE END=EOFIND1;

INPUT @2  TYPE @;

IF TYPE = '***' OR TYPE = '001' THEN DO;

  INPUT PART1   2-25

        TRIGJOB 58-65;

       PUTLOG 'GOT A TYPE MATCH =' TYPE=;

   FILE OUTFILE NOPRINT NOTITLES;

    PUT @9 PART1

        @34 TRIGJOB;

END;

ELSE IF TYPE = 'LEV' THEN DO;

   PUTLOG 'GOT AN LEV# TYPE =' TYPE=;

   INPUT PART1   2-25

         TRIGJOB 58-65;

   FILE OUTFILE NOPRINT NOTITLES;

    PUT @9 'LEV#      JOB NAME       TRIGGERING JOB';

END;

  ELSE DO;

   PUTLOG 'NO MATCH ON TYPE =' TYPE=;

   INPUT WHOLE1  1-80;

  FILE OUTFILE NOPRINT NOTITLES;

  PUT @1 WHOLE1 $CHAR80.;

END;

RUN;

Solution
‎07-09-2014 04:35 PM
Respected Advisor
Posts: 3,799

Re: Keep leading spaces and blank records

You need to use $CHAR as your INFORMAT.  Plus you cannot use LIST input but you don't mention that.

Change this INPUT WHOLE1  1-80;

to

input @1 whole1 $char80.;

You need to more the column pointer back to column 1.  You could also do it the read of type

change INPUT @2  TYPE @;

to

input @2 type @1 @;

This input might FLOWOVER so I would add an informat or column range

input @2 type $3. @1 @;

you can also add TRUNCOVER to infile statement to achieve similar effect.

Message was edited by: data _null_

Contributor
Posts: 23

Re: Keep leading spaces and blank records

Posted in reply to data_null__

Thanks for all your input - "Mission Accomplished" !!!!!!!

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 3782 views
  • 2 likes
  • 3 in conversation