7. Given a sequence whose terms are 1 or 2, the first term is 1, and there are $2^{k-1}$ 2's between the $k$-th 1 and the $(k+1)$-th 1, i.e., $1,2,1,2,2,1,2,2,2,2,1,2,2,2,2,2,2,2,2,1, \cdots$, then the sum of the first 1998 terms of this sequence is $\qquad$
7. 3985 We define the $k$-th group of the sequence as the $2^{k-1}+1$ terms starting with the $k$-th 1 and followed by $2^{k-1}$ 2s.

Let the 1998th term be in the $k$-th group, then $k$ is the smallest positive integer satisfying
$k+\left(1+2+2^{2}+\cdots+2^{k-1}\right)=2^{k}+k-1 \geqslant 1998$.
Since $2^{10}+10-1=10331998,
$$

so $k=11$.
Thus, $S_{1998}=2 \times 1998-11=3985$.