I am trying to write a file using some variables stored in an external file. I have a trouble using line holder(@@ with put statement) and loop. I like to put variables in some places in the file but the resut file I got repeats by each line of those variables. I just want those variables to be placed at one time as a chunk.
Here is the code I wrote:
data _null_;
set merged;
file 'c:outfile.txt';
put @1 "A" @4 &totaln.;
do i=1 to &totaln;
put @1 i @4 "L3 2 DW 1.7" @17 a @28 b @40 c @@;
end;
put;
put @1 "OL" @4 &totaln.;
do j=1 to &totaln.;
put @1 j put @4 "L3 2 DW 1.7" put @17 av @28 bv @40 cv @@;
end;
put;
put @1 "CI &totaln. AO";
put @1 "OP";
put @1 "KO" @4 "SL";
run;
&totaln. is the total number of count in the merged file that i made. 'Merged' contains a, b, c, av, ab, ac variables ( their rows are about 19 of them). So i want 19 rows of a,b,c variables below NE totaln line. And then the same thing for av, bv, cv below OL totaln line then the three lines of CI OP and Ko lines at the end of the outfile.
merged:
A B C av bv ac cnt
0.0268 676.9155 0.0347 0.9620294118 -2.131070959 0.031533299 1
0.0215 704.6740 0.2240 0.7738647059 -1.185638164 0.3506849035 2
0.0430 736.3752 0.2053 1.5611941176 -0.442240668 0.2434476134 3
0.0223 727.6945 0.1752 0.8075882353 -0.833957317 0.1725987826 4
0.0220 715.3714 0.1187 0.7434058824 -0.991003252 0.120438949 5
0.0287 754.1052 0.1824 0.8567470588 0.126161198 0.1685302022 6
outfille look:
NE 6
1 L3 2 DW 1.7 0.0268 676.9155 0.0347
2 L3 2 DW 1.7 0.0215 704.6740 0.2240
3 L3 2 DW 1.7 0.0430 736.3752 0.2053
4 L3 2 DW 1.7 0.0223 727.6945 0.1752
5 L3 2 DW 1.7 0.0220 715.3714 0.1187
6 L3 2 DW 1.7 0.0287 754.1052 0.1824
OL 6
1 L3 2 DW 1.7 0.9620294118 -2.131070959 0.031533299
2 L3 2 DW 1.7 0.7738647059 -1.185638164 0.3506849035
3 L3 2 DW 1.7 1.5611941176 -0.442240668 0.2434476134
4 L3 2 DW 1.7 0.8075882353 -0.833957317 0.1725987826
5 L3 2 DW 1.7 0.7434058824 -0.991003252 0.120438949
6 L3 2 DW 1.7 0.8567470588 0.126161198 0.1685302022
CI 6 AO
OP
KO SL