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
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_
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.
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;
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_
Thanks for all your input - "Mission Accomplished" !!!!!!!
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.