BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
srosenfe
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

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

4 REPLIES 4
ballardw
Super User

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.


srosenfe
Fluorite | Level 6

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;

data_null__
Jade | Level 19

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_

srosenfe
Fluorite | Level 6

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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 11610 views
  • 4 likes
  • 3 in conversation