reading file awk or while

While read line query !!!
Folks,

I am working on a file which has entries as follows. I am using while read line to generate desired output as follows.

filename1:

Name  : sdt2156157_ID
       NOS : 4567 [ sdt2156157/67 ]
       NOS : 2348 [ sdt2156157/48 ]  
Name  : sdt2156158_ID
       NOS : 4987 [ sdt2156158/87 ]
       NOS : 2332 [ sdt2156158/32 ]

Code:

while read line
do
nos=$(echo $line|grep NOS|awk '{print $3}')
name=$(echo $line|awk '{ if ($1 == "Name") print $5}')

echo $name
echo "INSERT -name $name -nos $nos to chart ABC;"

done < filename1

However I get following o/p.

Code:
sdt2156157_ID
INSERT -name mdt2156157_ig -nos to chart ABC;

INSERT -name -nos 4567 to chart ABC;

INSERT -name -nos 2348 to chart ABC;
Desired O/P is as follows.

Code:
sdt2156157_ID
INSERT -name mdt2156157_ig -nos 4567 to chart ABC;
APPEND -name mdt2156157_ig -nos 2348 to chart ABC;
Please guide me how can I save value from earlier line.

awk '
  $1=="Name" {n=$NF;nc=0;print n;next}
  $1=="NOS" { print ((nc)?"APPEND":"INSERT") "-name mdt" n " -nos " $3 " to chart ABC;"; nc++}' myFile

I get following error. I am runnning this on Solaris 5.9 Generic_118558-29 sun4u sparc SUNW,Sun-Fire-V240

awk '

> $1=="Name" {n=$NF;nc=0;print n;next}t" n " -nos " $3 " to chart ABC;"; nc++}'
> $1=="NOS" { print ((nc)?"APPEND":"INSERT") "-name mdt" n " -nos " $3 " to chart ABC;"; nc++}' junk0

awk: syntax error near line 3
awk: illegal statement near line 3

use 'nawk' instead of 'awk'.