Looping

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Looping

Sandy
Hi All,
 
I have syntax that count the responses for each questions (total 137 questions) and if the responses' count is less than 5 it makes the variable symis /blank.
 
The problem with the existing syntax is that it is very lengthy . I want to run the syntax in loop . I write the looping code but it is not working ..No error coming but transformation pending.
 

LOOPING SYNTAX :

VECTOR Count_Q=Count_Q1 TO Count_Q137.

FOR #I= 1 TO 137.

DO IF (Count_Q(#I) < 5).

comp P6_0001 = $sysmis.

comp P5_0001 = $sysmis.

comp P4_0001 = $sysmis.

comp P3_0001 = $sysmis.

comp P2_0001 = $sysmis.

comp P1_0001 = $sysmis.

comp Mean_0001 = $sysmis.

END IF.
END LOOP.

 EXISTING SYNTAX (WITHOUT LOOPING).

**FOR Q1.

DO IF (Count_Q1 < 5).

comp P6_0001 = $sysmis.

comp P5_0001 = $sysmis.

comp P4_0001 = $sysmis.

comp P3_0001 = $sysmis.

comp P2_0001 = $sysmis.

comp P1_0001 = $sysmis.

comp Mean_0001 = $sysmis.

END IF.

**FOR Q2.

DO IF (Count_Q2 < 5).

comp P6_0001 = $sysmis.

comp P5_0001 = $sysmis.

comp P4_0001 = $sysmis.

comp P3_0001 = $sysmis.

comp P2_0001 = $sysmis.

comp P1_0001 = $sysmis.

comp Mean_0001 = $sysmis.

END IF.

..

Same code till Q137.

As i am new to looping and vector please review my created syntax and correct if if wrong or suggest better way to do the same .

Thanks in advance !