Writing an If condition within a Loop in SPSS -


i want have if condition within loop. long id < 10, check if modc_initial equal modc, if true set d = 12

this code tried bit not working, can please help.

loop if (id lt 10)

if(modc_initial eq modc))

compute d = 12.

end loop.

execute.

you can either use 1 line conditional of form if (condition) d = 12. or multiple line do if. below provide example of do if adapted syntax.

data list free / id modc modc_initial. begin data 1 3 3 2 3 5 12 1 1 end data.  loop if (id lt 10). if (modc_initial eq modc).   compute d = 12. end if. end loop if (d = 12). execute. 

note had period missing in original syntax on initial loop. added end loop condition, otherwise code written go until maximum set number of loops per system.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -