You will need to use a combination of INPUT with column location pointer to read up each of your data records, first reading the leading columns followed by your columnar-oriented data columns. Then if you decide it is appropriate, only OUTPUT under the appropriate conditions, as you decide while doing your INPUT logic in a DATA step. With this approach/technique, you will likely need to consider using a RETAIN statement for the variables that are blank, as you have described. A sample DATA step is shown below using the SAS DATA step programming techniques mentioned above.
Scott Barry
SBBWorks, Inc.
DATA ;
INFILE DATALINES;
INPUT @1 VAR1 $CHAR2. @4 VAR2 $CHAR1. @6 VAR3 2. VAR4 2.;
IF VAR1 = ' ' THEN VAR1 = LVAR1;
IF VAR2 = ' ' THEN VAR2 = LVAR2;
PUTLOG '>BEFORE_OUTPUT>' / _ALL_;
OUTPUT;
LVAR1 = VAR1;
LVAR2 = VAR2;
RETAIN LVAR1 LVAR2 ' ';
DATALINES;
AA B 1122
3344
BB C 2233
4455
RUN;