Pattern matching...of almost same lines

Hi all I am trying to process some data sample input is like this

 VARIABLE : T
                        axis TDAY
             TIME     : 02-FEB-2004 17:54
          19755.
             VARIABLE : quality flag
             FILENAME : 1900054_prof.nc
             Z        : 41
        "11111111111111111111111111111111111111111111111111 "
             VARIABLE : quality flag
             FILENAME : 1900054_prof.nc
             Z        : 41
        "21111111171111119111111111111118111111111111111111 "
             VARIABLE : quality flag
             FILENAME : 1900054_prof.nc
             Z        : 41
        "31111111161111111111151111111111111111111111112111 "
             DATA SET: ./1900054_prof.nc
             X: 0.5 to 51.5
             Z: 41
	VARIABLE : T
                        axis TDAY
             TIME     : 02-FEB-2005 17:19
          19756.
             VARIABLE : quality flag
             FILENAME : 1900055_prof.nc
             Z        : 41
        "11111111111111111111111111111111111111111111111111 "
             VARIABLE : quality flag
             FILENAME : 1900055_prof.nc
             Z        : 41
        "21111111171111119111111111111118111111111111111111 "
             VARIABLE : quality flag
             FILENAME : 1900055_prof.nc
             Z        : 41
        "31111111161111111111151111111111111111111111112111 "
             DATA SET: ./1900055_prof.nc
             X: 0.5 to 51.5
             Z: 41

trying to get output like this columns wise by spitting flags coded as string

1 2 3
1 1 1
1 1 1
.......
.......
.......
1 2 3
1 1 1
1 1 1
.......
.......
.......

so far i tried like this

awk '
	function out(){
			for(i=1;i<=n;i++)
			print PS
		      }
			
          /Z        :/{		getline	
				gsub(/[ \t]/,"")
				gsub(/\"/,"")
				n=split($0,PS,r)
				out()
                      }'  file

not getting right output please help..if its possible to store 3 flags in 3 different array it will be helpful for me to process in END block.

I have to write this way because the awk version what I have doesnt allow split to use NULL as filed seperator :frowning:

 
awk 'function out() {
for(k=1;k<=v;k++){
print A[k]" "B[k]" "C[k]}}
/Z        :/{getline
j++
gsub(/[ \t]/,"")
gsub(/\"/,"")
v=length($0)
for(i=1;i<=v;i++)
{if(j==1){A=substr($0,i,1)}
 if(j==2){B=substr($0,i,1)}
 if(j==3){C=substr($0,i,1)}
}
if(j==3){out();j=0}}' filename

Can you post an example output on how you like it to be.
Not sure what you try to do.

Thank you so much vidyadhar85