Hi:
Let's assume that your input data was in a SAS dataset, called TESTDATA, as you described in your post, with the variables DATE, AGE1 and AGE2 (DATE is shown here in Julian form, although, internally, it would not be stored as a JULIAN date in the SAS dataset):
[pre]
06325 00010 00020
06323 01001 01006
06322 02000 00000
[/pre]
In that case, this program with a simple do loop can create an output file called C:\TEMP\INFO_OUT.TXT, as you described:
[pre]
data _null_;
set testdata;
file 'c:\temp\info_out.txt';
do i = age1 to age2 by 1;
put @1 date julian5. i z5.;
end;
if age2 = 00000 then do;
put @1 date julian5. age1 z5.;
end;
run;
[/pre]
The AGE1 variable is used as the start value for the DO loop and the AGE2 variable is used as the stop value for the DO loop. For every time through the LOOP, the PUT statement will write a line to the file defined by the FILE statement, using the variables provided in the PUT statement. In the case of your 3rd row, AGE1 is 2000 and AGE2 is 0 -- so the loop would never execute for that row -- the loop can't go from 2000 to 0 by 1. However, the IF statement then comes into play. since Age2 is 0, then a different PUT statement is executed for that record, where the date is written, followed by the value for AGE1.
If, on the other hand, your INPUT file is a "flat" file or "raw text" file, (not a SAS dataset) and you want to read it in and then immediately write out the new datalines, your program would look something like this:
[pre]
data _null_;
infile 'c:\temp\input_file.txt';
input date : julian. age1 age2;
file 'c:\temp\output_file.txt';
do i = age1 to age2 by 1;
put @1 date julian5. i z5.;
end;
if age2 = 00000 then do;
put @1 date julian5. age1 z5.;
end;
run;
[/pre]
In this program, the INFILE statement is pointing to the "raw" file, c:\temp\input_file.txt, while the INPUT statement is parsing each dataline and putting the values from the dataline into variables. Then the FILE statement is pointing to the ASCII text output file that is being created, c:\temp\output_file.txt -- and the DO loops and IF statement are the same as in the first example to write the new datalines to the new output file.
If you need more help with this task, then your best bet is to contact SAS Technical Support for help with INFILE/FILE and INPUT/PUT statements.
cynthia